+ 3

Help with .py files please!

how can I run .py file when I click the button in my own program using Tkinter lib.? for example, I created a window with Tkinter and add there some buttons. when I click it, I want to run program that situated in the same folder, for example "Date.py" what options must have "button"?

12th Mar 2017, 3:47 PM
Богдан
Богдан - avatar
1 Resposta
0
I think you should import it at first. (from Date import * - but I do not like name "Date", I believe it should be somehow renamed. Why? Because there is from datetime import date) then (it depends on your code in Date.py), you can call it like your_button = Button(None, text="Your text", command=command_from_Date.py).grid(row=0, column=0) command_from_Date.py - maybe create some function, that joins all needed code in Date.py... Something like this :) I am also new in tkinter :)
12th Mar 2017, 11:00 PM
Stanislav Syarkevich
Stanislav Syarkevich - avatar