How Do I Handle On Load Event?
I have a load_words function which I would like to be executed when the application starts. In C#, I would create the following method: private void Form1_Load(object sender, Event
Solution 1:
from tkinter import *
class Application(Frame):
def __init__(self, parent):
self.parent = parent
### put HERE the "onLoad()" code ###
Frame.__init__(self, parent)
# self.create_widgets()
...
def main():
root = Tk()
root.geometry('600x900-0+0') # 120 * 50 ppixels in top right corner of desktop
app = Application(root)
app.master.title('Sample application')
app.mainloop()
if __name__ == '__main__':
main()
See also here for more about events in tkinter.
Happy coding :) . And don't get disappointed using tkinter. There are many other options of GUIs you can use in Python like e.g. wxPython which using will be probably easier for a C# programmer.
Post a Comment for "How Do I Handle On Load Event?"