Why does my personnalized frame doesn't stay when I add a smaller widget

时间:2016-04-12 00:44:00

标签: tkinter python-3.5 ttk

Considering tkinter use Tk 8.6 in python 3.5.

Note : In the following codes, s refer to an instance of ttk.Style.

I have a Frame with a style I made. It works fine. I size it 562x750 because it is the image size. Nothing wrong with it. Here's the code if it is needed :

s.mainframeImage = tk.PhotoImage(file = os.path.join(IMG_DIR, "base_img", "SWTORLogo.png"))
s.element_create("mainframe.background", "image", s.mainframeImage, sticky = "nswe", height = 562, width = 750)
s.layout("mainframe.TFrame", [("Frame.border", {"sticky": "nswe", "children": [("mainframe.background",
            {"sticky": "nswe"})]})])

Here is the combobox style I made if it is needed. I only changed the background (Combobox.field).

s.topComboboxImage = tk.PhotoImage(file = os.path.join(IMG_DIR, "base_img", "combobox_top.png"))
s.element_create("topCombobox.field", "image", s.topComboboxImage, sticky = "nswe", height = 65, width = 750)
s.layout("topCombobox.TCombobox", [("topCombobox.field", {"children": [("Combobox.downarrow",
            {"side": "right", "sticky": "ns"}), ("Combobox.padding", {"children": [("Combobox.textarea",
            {"sticky": "nswe"})], "expand": "1", "sticky": "nswe"})], "sticky": "nswe"})])

So... Assuming the code above is instantiated.. I should have no problem making them appear in a window. And as long as I don't use the frame as parent for the combobox, everything appears. Problems start when I do. Here's my the code I use :

myApp = tk.Tk()
getStyle(myApp)
myApp.me = ttk.Frame(myApp, style = "mainframe.TFrame", height = 562, width = 750)
myApp.me.grid(sticky = "nswe")
myApp.me.me2 = ttk.Combobox(myApp.me, style = "topCombobox.TCombobox")
myApp.me.me2.grid(column = 1, row = 1)

getStyle(myApp) is a function I use to order the creation of my theme.

So the question is : Why does the frame disappear when I give it to the combobox as parent? The combobox should be smaller.

0 个答案:

没有答案