Jul-07-2019, 05:06 PM
I have been asked about information on how to size a ttk Separator using the .pack or .place methods.
In the code below the separator is showing however it is not the length required. The separator is supposed to go from the current placement (the bottom of the brown header and run to the bottom of the space to the brown footer in the image. As seen when running the code it only runs from the brown header to a little more then half way down.
Is there a way to resize the length and place it in the correct position?
I have attached the image being used in the code.
Code:
In the code below the separator is showing however it is not the length required. The separator is supposed to go from the current placement (the bottom of the brown header and run to the bottom of the space to the brown footer in the image. As seen when running the code it only runs from the brown header to a little more then half way down.
Is there a way to resize the length and place it in the correct position?
I have attached the image being used in the code.
Code:
from tkinter import * from tkinter import ttk import win32api import win32con import pywintypes root = Tk() root.title(Prehistoric Life) devmode = pywintypes.DEVMODEType() devmode.PelsWidth = 1280 devmode.PelsHeight = 720 devmode.Fields = win32con.DM_PELSWIDTH | win32con.DM_PELSHEIGHT win32api.ChangeDisplaySettings(devmode, 0) header=PhotoImage(file='header.gif') w = 1280 h = 720 ws = root.winfo_screenwidth() hs = root.winfo_screenheight() x = (ws/2) - (w/2) y = (hs/2) - (h/2) root.geometry('%dx%d+%d+%d' % (w, h, x, y)) root.state('zoomed') panel1 = Label(root, image=header) panel1.pack(side='top', fill='both', expand='yes') #-------------------------------- LABELS --------------------------------------- name = Label(root, text = 'Name :', font = ('arial',10,'bold'), bg = '#E2DED6') name.place(x=90, y = 200) meaning = Label(root, text = 'Meaning :', font = ('arial',10,'bold'), bg = '#E2DED6') meaning.place(x=72, y = 230) pronounce = Label(root, text = 'Pronounciation :', font = ('arial',10,'bold'), bg = '#E2DED6') pronounce.place(x=30, y = 260) period = Label(root, text = 'Period :', font = ('arial',10,'bold'), bg = '#E2DED6') period.place(x=85, y = 290) group = Label(root, text = 'Group :', font = ('arial',10,'bold'), bg = '#E2DED6') group.place(x=89, y = 320) size = Label(root, text = 'Size :', font = ('arial',10,'bold'), bg = '#E2DED6') size.place(x=100, y = 350) lived = Label(root, text = 'Lived :', font = ('arial',10,'bold'), bg = '#E2DED6') lived.place(x=93, y = 380) diet = Label(root, text = 'Diet :', font = ('arial',10,'bold'), bg = '#E2DED6') diet.place(x=102, y = 410) fossils = Label(root, text = 'Fossils :', font = ('arial',10,'bold'), bg = '#E2DED6') fossils.place(x=85, y = 440) #------------------------------ ENTRY BOX -------------------------------------- eName = Entry(root, width = 30, bg = '#d8d3cf') eName.place(x=150, y = 203) eMeaning = Entry(root, width = 30, bg = '#d8d3cf') eMeaning.place(x= 150, y = 233) ePronounce = Entry(root, width = 30, bg = '#d8d3cf') ePronounce.place(x= 151, y = 263) ePeriod = Entry(root, width = 30, bg = '#d8d3cf') ePeriod.place(x= 151, y = 293) eGroup = Entry(root, width = 30, bg = '#d8d3cf') eGroup.place(x= 151, y = 323) eSize = Entry(root, width = 30, bg = '#d8d3cf') eSize.place(x= 151, y = 353) eLived = Entry(root, width = 30, bg = '#d8d3cf') eLived.place(x= 151, y = 383) eDiet = Entry(root, width = 30, bg = '#d8d3cf') eDiet.place(x= 151, y = 413) eFossils = Entry(root, width = 30, bg = '#d8d3cf') eFossils.place(x= 151, y = 443) #-------------------------------- SEPARATOR ------------------------------------ s = ttk.Separator(panel1, orient=VERTICAL) s.pack(side=LEFT, fill="y", padx=345, pady=177) #------------------------------- TEXT WIDGET ----------------------------------- factFile = Text(root, x=360, y= 210, height=27, width=60, bg = '#d8d3cf', wrap=WORD) factFile.place(x=360, y=200) for line in range(1001): factFile.insert(END, "Row: " + str(line + 1)) root.mainloop() win32api.ChangeDisplaySettings(None, 0)
"Often stumped... But never defeated."