tkinter

Tkinter: Set 0, 0 coords on the bottom of a canvas

故事扮演 提交于 2021-01-27 12:43:39
问题 When I usually create a canvas, the (0, 0) coord is place on the top left corner of it. Now I want to set it on the bottom left corner. I think I have to set the "scrollbarregion" but I can't understand how to do it. Can someone explain? 回答1: The tkinter canvas does not support changing the coordinate system. You can scroll the canvas so that 0,0 appears in the bottom left corner, but that won't affect the coordinate system. Point (1,1) will always be to the right and below the point (0,0).

Tkinter: Set 0, 0 coords on the bottom of a canvas

久未见 提交于 2021-01-27 12:33:27
问题 When I usually create a canvas, the (0, 0) coord is place on the top left corner of it. Now I want to set it on the bottom left corner. I think I have to set the "scrollbarregion" but I can't understand how to do it. Can someone explain? 回答1: The tkinter canvas does not support changing the coordinate system. You can scroll the canvas so that 0,0 appears in the bottom left corner, but that won't affect the coordinate system. Point (1,1) will always be to the right and below the point (0,0).

In Tkinter how to pass a called function as argument?

雨燕双飞 提交于 2021-01-27 12:10:36
问题 In Tkinter for constructing the menubar with the <menu_item>.add_command() we need a string for the accelerator argument which will create the hotkey binding for a command. I created a method, which is checking if the user's platform is Mac or other, and if it is, then returns the Command key string combined with the other keys. But it doesn't work -> the menu is building, if I click on the menu-item it is working, but not working with the hot-keys. ALthough I can see the ⌘ + N in the menu..

Is there a way to change tkcalendar's color?

ぐ巨炮叔叔 提交于 2021-01-27 12:00:59
问题 I'm trying to make tkcalendar blend in with my window. import tkinter from tkcalendar import Calendar window = tkinter.Tk() window.configure(background = "black") cal = Calendar(window, background = "black" , disabledbackground = "black" , borderbackground = "black" , headersbackground = "black" , normalbackground = "black" ) cal.config(background = "black") cal.pack() window.mainloop() I've read through the tkcalendar documentation and tried changing all the style elements by calling the

Is there a Tkinter/ttk style reference?

谁都会走 提交于 2021-01-27 09:01:33
问题 With ttk one can produce code like the following: style.configure('TButton', font='helvetica 24',foreground='red', padding=10) Is there a list of the different options (e.g. font, foreground, padding) and the values (e.g. helvetica 24, red, 10) associated with each of them? I've been searching online and have yet to find such a reference. Also, is there a css-like thing we can use to style a TKinter GUI? Or is ttk my best bet? 回答1: Most information you should find in Tk Reference Manual. See

How to replace the “About Tkinter” menu in Python on OSX

半腔热情 提交于 2021-01-27 07:33:31
问题 Edit: I am referring to the OSX application menu, which contains the About and Preference menu items (along with others). Perhaps this will be another easy one for someone who knows the right search terms, but after spending hours tracing code in IDLE and searching the net, I haven't quite been able to connect the dots. I'm trying to replace the standard About menu in Python. IDLE does this at least part-way; the menu is still named "About Python" but it displays the IDLE About window. When

How to replace the “About Tkinter” menu in Python on OSX

Deadly 提交于 2021-01-27 07:33:06
问题 Edit: I am referring to the OSX application menu, which contains the About and Preference menu items (along with others). Perhaps this will be another easy one for someone who knows the right search terms, but after spending hours tracing code in IDLE and searching the net, I haven't quite been able to connect the dots. I'm trying to replace the standard About menu in Python. IDLE does this at least part-way; the menu is still named "About Python" but it displays the IDLE About window. When

How to make tkinter button widget take up full width of grid

╄→гoц情女王★ 提交于 2021-01-27 07:23:33
问题 I've tried this but it didn't help. I'm making a calculator program. I've made this so far: from tkinter import * window = Tk() disp = Entry(window, state='readonly', readonlybackground="white") disp.grid(column=0, row=0, columnspan=4) #row 1 seven = Button(window, text="7", command=Seven) seven.grid(column=1,row=1) eight = Button(window, text="8", command=Eight) eight.grid(column=2,row=1) nine = Button(window, text="9", command=Nine) nine.grid(column=3,row=1) divide = Button(window, text="÷"

How to make tkinter button widget take up full width of grid

谁都会走 提交于 2021-01-27 07:21:44
问题 I've tried this but it didn't help. I'm making a calculator program. I've made this so far: from tkinter import * window = Tk() disp = Entry(window, state='readonly', readonlybackground="white") disp.grid(column=0, row=0, columnspan=4) #row 1 seven = Button(window, text="7", command=Seven) seven.grid(column=1,row=1) eight = Button(window, text="8", command=Eight) eight.grid(column=2,row=1) nine = Button(window, text="9", command=Nine) nine.grid(column=3,row=1) divide = Button(window, text="÷"

Why only some Tkinter callback functions need to have an argument but others don't

浪子不回头ぞ 提交于 2021-01-27 07:15:19
问题 I'm using Python 2.7, if that matters. Here is a code I wrote for fun: def p(): root = Tk() def cmd(event): print int(slider.get()) slider = Scale(root, orient = "horizontal", from_ = 0, to = 100, command = cmd, state = "disabled") def enable(): slider.config(state = "active") b = Button(root, text = "Enable slider", command = enable) b.grid() slider.grid(row = 1) root.mainloop() For this code, I'm wondering why the command for Scale requires an event, but that for Button does not. It seems