How can I let the Tkinter Button command do more than one function?
Use something like:
def callback(): functionone(x) #tab me woot functiontwo(y) #tab me woot
As a base for your callback code.
* Sorry if this is incorrect; I'm new to python! vegaseat, please correct me if I'm wrong.
Yes linux, that would be the simplest way to do it!
Python allows you to pass functions as arguments to a function. This code might give you more flexibility ...
# giving a Tkinter Button command two (or multiple) functions to run import Tkinter as tk def do_two(s, f1, f2): """run 2 functions f1 and f2""" f1(s) # after 2 sec run function f2 root.after(2000, f2) root = tk.Tk() root.title('click me') s = '123' f1 = root.title f2 = root.destroy # using lambda to pass string s and two functions f1 and f2 as arguments q1 = lambda: do_two(s, f1, f2) b2 = tk.Button(root, text=" click to show 123, then after 2 sec quit ", command=q1) b2.pack() root.mainloop()
There's one other way that I've found, although sometimes it feels like cheating: bind another function to the mouseclick of that button.
button = Button(text="Two Functions", command=f1) button.pack() button.bind('<ButtonRelease-1>', f2) button.focus_force()
Thus the usual command is to perform
f1 , while when the mouse has clicked the button and released,
As far as I can tell, you can only bind one function to a particular event. Although I suppose you could bind a third function to the click (rather than the release), I've found that it tends to be jarring for the user at times.
I've been searching for another way around this problem for ages, to no avail...
I have the following query, to group the records but not the group was thanks to you only help, the end when running excel file view:
SELECT TOP (100) PERCENT ...
I have a datagridvied with several columns and one with date and the format is
Me.DataGridView1.Columns("Doopdatum").DefaultCellStyle.Format = "yyyy - MM - dd dddd"
Me.DataGridView1.Columns("Doopdatum").DefaultCellStyle.Format = "dddd dd - MM ...
i want to print a persian file by thermal printer..
i can print an english file esily..but i face the proble while printing persian text..
i think i ...