python 2.7.13 fill tabs (from Notebook) with widgets -
i'm having trouble filling these tabs other widgets, here images of current state:
#imports import tkinter tk #to able use "button" tk.button import ttk tkinter import * ttk import * #the gui class mywindow(frame): def __init__(self,master=none): frame.__init__(self,master) #run parent's initiation self.initui() #construct ui def initui(self): #make rows , columns visible "minsize" row in range(5): self.grid_rowconfigure(row,minsize=25) col in range(5): self.grid_columnconfigure(col,minsize=10) #make parent window appears self.grid() #make 2 tabs: sap2000, etabs n=notebook(self.master) n.grid(row=0,column=1) #construct tab etabs fetabs = frame(n) tetabs= n.add(fetabs,text='etabs') impetabs=tk.button(tetabs,text="import etabs model",width=20,relief=tk.raised) impetabs.grid(row=0,column=1) #construct tab sap2000 fsap = frame(n) tsap = n.add(fsap,text='sap2000') impsap=tk.button(fsap,text="import sap2000 model",width=20,relief=tk.raised) impsap.grid(row=1,column=1) seltwtmdfcmbox=ttk.combobox(tsap,justify=tk.center,state='readonly') seltwtmdfcmbox.grid(row=1,column=3)
in case of suggestions use .pack()
or .place()
, why i've chosen .grid()
:-
also, i've tried .pack()
manager before using assigns tabs in wrong place, i've used .place(x=0,y=0,relheight=1,relweight=1)
notebook's object n
make tabs rightly positioned, widgets disappear usage of .place(x=any value, y=any value)
or .grid_location(x=any value, y = value)
.
then changed .place()
of widgets .pack()
,, , .pack()
puts widgets on top of each other, imagine how useless button when combobox takes same place , hide it!, returned .grid(row = value, column = value)
widgets , .grid()
main window, however, got weird results, namely, tabs couldn't recognize widgets belong them exception of 1 button, , other widgets placed outside tabs.
what missing, considering i'm new tkinter?!
the whole point of creating class inherits frame
in class inside of frame. aren't doing that.
you setting master of notebook same master of frame. instead, needs frame:
n=notebook(self)
in similar vein, when want place windows in tab, master needs frame, not results of call n.add
. reason being, n.add(...)
returns none
. when use master combobox
, button
, become children of root window.
Comments
Post a Comment