Posts: 11
Threads: 4
Joined: Jan 2019
Perhaps not working properly is the better term here. If you:
import tkinter as tk
from tkinter import ttk
class MyApp(ttk.Frame):
def __init__(self, parent, *args, **kwargs)
ttk.Frame.__init__(self, parent, *args, **kwargs)
self.parent = parent
lb = tk.Listbox(self, width=30, height=20)
lb.grid(row=0, column=0, padx=5, pady=5, ipadx=5, ipady=5)
if __name__ == "__main__":
root = tk.Tk()
MyApp(root)
root.mainloop() The Inner padding works, bout only on one side, that being the right side and the bottom. I have some things in the listbox and i just want to juke them off the edge of the box for readability. Any suggestions?
Posts: 536
Threads: 0
Joined: Feb 2018
Feb-19-2019, 11:55 PM
(This post was last modified: Feb-19-2019, 11:56 PM by woooee.)
The padding is what you declare it as (run code below). You are possibly overlaying it with something else. You will have to comment lines in your complete program, and then run it, to see which line is the offender. import tkinter as tk
from tkinter import ttk
class MyApp():
def __init__(self, parent):
self.parent = parent
lb = tk.Listbox(self.parent, width=30, height=20)
lb.grid(row=0, column=0, padx=5, pady=5, ipadx=5, ipady=5)
for item in ["one", "two", "three", "four", "five"]:
lb.insert("end", item)
print(lb.grid_info())
if __name__ == "__main__":
root = tk.Tk()
MyApp(root)
root.mainloop()
Posts: 11
Threads: 4
Joined: Jan 2019
(Feb-19-2019, 11:55 PM)woooee Wrote: The padding is what you declare it as (run code below). You are possibly overlaying it with something else. You will have to comment lines in your complete program, and then run it, to see which line is the offender.
So when I run that I get:
Error: {'in': <tkinter.ttk.Frame object .!frame>, 'column': 0, 'row': 1, 'columnspan': 1, 'rowspan': 20, 'ipadx': 5, 'ipady': 5, 'padx': 20, 'pady': (0, 20), 'sticky': ''}
Does that mean the parent frame is the culprit?
Posts: 536
Threads: 0
Joined: Feb 2018
Feb-20-2019, 09:51 PM
(This post was last modified: Feb-20-2019, 09:51 PM by woooee.)
There is no way to tell from the code you posted.
Quote:I have some things in the listbox and i just want to juke them off the edge of the box for readability.
What does this mean? You don't have anything in the Listbox in the code posted above. Stop guessing and start testing.
Posts: 74
Threads: 0
Joined: Mar 2017
Hi woooee
Quote:What does this mean? You don't have anything in the Listbox in the code posted above. Stop guessing and start testing.
I think you didn't test your script visually either. Because even with listcontains the ipadx and ipady aren't active!
Maybe this could be a work around:
import tkinter as tk
class MyApp(tk.Frame):
def __init__(self, parent, **kwargs):
self.parent = parent
tk.Frame.__init__(self, parent, **kwargs)
list_item_values = ["one", "two", "three", "four", "five"]
lb = tk.Listbox(self, width=30, height=20, bd=0, highlightthickness=0)
lb.grid(row=0, column=0, padx=5, pady=5)
lb.insert('end', *list_item_values)
if __name__ == "__main__":
root = tk.Tk()
MyApp(root, relief='sunken', bd=1, bg='white').pack(padx=5, pady=5)
root.mainloop() Greetings wuf
|