Tkinter in python - Thanu - 03-24-2019
I am currently working on a project thats due next week and im not sure where or why my code is breaking. Im using tkinter in a class, not sure how to post the full code here, would appreciate if someone let me know
RE: Tkinter in python - Oblivious - 03-24-2019
[code] opening bracket > /code]
RE: Tkinter in python - Thanu - 03-24-2019
Code: from tkinter import *
from tkinter import ttk
from tkinter import messagebox as ms
import datetime
class Gui:
def __init__(self):
self.window = Tk()
self.window.title("School Life!")
self.window.geometry("1024x768")
self.window.configure(background="azure")
self.username = StringVar()
self.password = StringVar()
self.n_username = StringVar()
self.n_password = StringVar()
self.role = IntVar()
self.homescreen()
def menubar(self):
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def test(self):
print("It works")
def na_homescreen_del(self):
self.window.destroy()
self.new_account_gui()
def mm_homescreen_del(self):
self.window.destroy()
self.mainmenu()
def tt_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_timetable()
def hw_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_homework()
def hs_newaccount_del(self):
self.new_acc_window.destroy()
self.homescreen()
def new_account_gui(self):
self.new_acc_window = Tk()
self.new_acc_window["padx"] = 5
self.new_acc_window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "na" stands for 'new account'
header_label = Label(self.new_acc_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X, side=TOP)
na_frame = LabelFrame(self.new_acc_window, text="Create A New Account", relief=RIDGE)
na_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
na_username_label = Label(na_frame, text="Username")
na_username_label.grid(row=2, column=2, sticky=W, pady=3)
na_password_label = Label(na_frame, text="Password")
na_password_label.grid(row=3, column=2, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their new user credentials
na_username_entry = Entry(na_frame, width=30, textvariable=self.n_username)
na_username_entry.grid(row=2, column=3, sticky=W, pady=3)
na_password_entry = Entry(na_frame, width=30, textvariable=self.n_password, show="*")
na_password_entry.grid(row=2, column=3, sticky=W, pady=3)
# Creation of buttons
na_login_button = ttk.Button(na_frame, text="Go Back", width=10, command=self.hs_newaccount_del())
na_login_button.grid(row=4, column=2)
na_create_new_button = ttk.Button(na_frame, text="Create New Account", width=12, command=self.test) # This needs to change to put the user inputs as the username and password.
na_create_new_button.grid(row=4, column=3)
na_quit_button = ttk.Button(na_frame, text="Quit", width=12, command=self.new_acc_window.quit)
na_quit_button.grid(row=4, column=3)
na_current_date = str(datetime.datetime.now().date)
na_date_entry = Entry(na_frame, width=10, textvariable=na_current_date)
na_date_entry.grid(row=0, column=10)
def homescreen(self):
self.window["padx"] = 5
self.window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "hs" stands for 'home screen'
header_label = Label(self.window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
hs_frame = LabelFrame(self.window, text="Log In", labelanchor=N, relief=RIDGE)
hs_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
hs_username_label = Label(hs_frame, text="Username", font=("", 15))
hs_username_label.grid(row=25, column=23, sticky=W, pady=3)
hs_password_label = Label(hs_frame, text="Password", font=("", 15))
hs_password_label.grid(row=26, column=23, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their log in details
hs_username_entry = Entry(hs_frame, width=15, textvariable=self.username)
hs_username_entry.grid(row=25, column=24, sticky=W, pady=3)
hs_password_entry = Entry(hs_frame, width=15, textvariable=self.password, show="*")
hs_password_entry.grid(row=26, column=24, sticky=W, pady=3)
# Creation of buttons
hs_login_button = ttk.Button(hs_frame, text="Sign In", width=30, command=self.mm_homescreen_del())
hs_login_button.grid(row=30, column=19)
hs_create_new_button = ttk.Button(hs_frame, text="Create New Account", width=30, command=self.na_homescreen_del())
hs_create_new_button.grid(row=30, column=22)
hs_quit_button = ttk.Button(hs_frame, text="Quit", width=40, command=self.window.quit)
hs_quit_button.grid(row=30, column=25)
hs_date_label = Label(hs_frame, text=datetime.datetime.now().strftime('%d-%m-%Y'))
hs_date_label.grid(row=1, column=0)
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def mainmenu(self):
self.mainmenu_window = Tk()
self.mainmenu_window["padx"] = 5
self.mainmenu_window["pady"] = 5
header_label = Label(self.mainmenu_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
mm_frame = LabelFrame(self.mainmenu_window, text="Main Menu", relief=RIDGE)
mm_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
# Creation of buttons
mm_timetable_button = ttk.Button(mm_frame, text="My Timetable", width=500, command=self.test)
mm_timetable_button.grid(row=1, column=1)
mm_homework_button = ttk.Button(mm_frame, text="My Homework", width=500, command=self.test)
mm_homework_button.grid(row=1, column=2)
mm_classes_button = ttk.Button(mm_frame, text="My Classes", width=500, command=self.test)
mm_classes_button.grid(row=1, column=3)
def my_timetable(self):
self.timetable_window = Tk()
self.timetable_window.title(self.username.get() + "'s Timetable")
tt_frame = LabelFrame(self.timetabel_window, text="Timetable", relief=RIDGE)
tt_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
def my_homework(self):
self.
program = Gui()
program.window.mainloop()
need to add a few more functions and connect this to my database python file, but im not too sure where the code is breaking (also thanks for the reply)
RE: Tkinter in python - darkninja1980 - 03-24-2019
(03-24-2019, 05:31 AM)Thanu Wrote: Code: from tkinter import *
from tkinter import ttk
from tkinter import messagebox as ms
import datetime
class Gui:
def __init__(self):
self.window = Tk()
self.window.title("School Life!")
self.window.geometry("1024x768")
self.window.configure(background="azure")
self.username = StringVar()
self.password = StringVar()
self.n_username = StringVar()
self.n_password = StringVar()
self.role = IntVar()
self.homescreen()
def menubar(self):
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def test(self):
print("It works")
def na_homescreen_del(self):
self.window.destroy()
self.new_account_gui()
def mm_homescreen_del(self):
self.window.destroy()
self.mainmenu()
def tt_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_timetable()
def hw_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_homework()
def hs_newaccount_del(self):
self.new_acc_window.destroy()
self.homescreen()
def new_account_gui(self):
self.new_acc_window = Tk()
self.new_acc_window["padx"] = 5
self.new_acc_window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "na" stands for 'new account'
header_label = Label(self.new_acc_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X, side=TOP)
na_frame = LabelFrame(self.new_acc_window, text="Create A New Account", relief=RIDGE)
na_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
na_username_label = Label(na_frame, text="Username")
na_username_label.grid(row=2, column=2, sticky=W, pady=3)
na_password_label = Label(na_frame, text="Password")
na_password_label.grid(row=3, column=2, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their new user credentials
na_username_entry = Entry(na_frame, width=30, textvariable=self.n_username)
na_username_entry.grid(row=2, column=3, sticky=W, pady=3)
na_password_entry = Entry(na_frame, width=30, textvariable=self.n_password, show="*")
na_password_entry.grid(row=2, column=3, sticky=W, pady=3)
# Creation of buttons
na_login_button = ttk.Button(na_frame, text="Go Back", width=10, command=self.hs_newaccount_del())
na_login_button.grid(row=4, column=2)
na_create_new_button = ttk.Button(na_frame, text="Create New Account", width=12, command=self.test) # This needs to change to put the user inputs as the username and password.
na_create_new_button.grid(row=4, column=3)
na_quit_button = ttk.Button(na_frame, text="Quit", width=12, command=self.new_acc_window.quit)
na_quit_button.grid(row=4, column=3)
na_current_date = str(datetime.datetime.now().date)
na_date_entry = Entry(na_frame, width=10, textvariable=na_current_date)
na_date_entry.grid(row=0, column=10)
def homescreen(self):
self.window["padx"] = 5
self.window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "hs" stands for 'home screen'
header_label = Label(self.window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
hs_frame = LabelFrame(self.window, text="Log In", labelanchor=N, relief=RIDGE)
hs_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
hs_username_label = Label(hs_frame, text="Username", font=("", 15))
hs_username_label.grid(row=25, column=23, sticky=W, pady=3)
hs_password_label = Label(hs_frame, text="Password", font=("", 15))
hs_password_label.grid(row=26, column=23, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their log in details
hs_username_entry = Entry(hs_frame, width=15, textvariable=self.username)
hs_username_entry.grid(row=25, column=24, sticky=W, pady=3)
hs_password_entry = Entry(hs_frame, width=15, textvariable=self.password, show="*")
hs_password_entry.grid(row=26, column=24, sticky=W, pady=3)
# Creation of buttons
hs_login_button = ttk.Button(hs_frame, text="Sign In", width=30, command=self.mm_homescreen_del())
hs_login_button.grid(row=30, column=19)
hs_create_new_button = ttk.Button(hs_frame, text="Create New Account", width=30, command=self.na_homescreen_del())
hs_create_new_button.grid(row=30, column=22)
hs_quit_button = ttk.Button(hs_frame, text="Quit", width=40, command=self.window.quit)
hs_quit_button.grid(row=30, column=25)
hs_date_label = Label(hs_frame, text=datetime.datetime.now().strftime('%d-%m-%Y'))
hs_date_label.grid(row=1, column=0)
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def mainmenu(self):
self.mainmenu_window = Tk()
self.mainmenu_window["padx"] = 5
self.mainmenu_window["pady"] = 5
header_label = Label(self.mainmenu_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
mm_frame = LabelFrame(self.mainmenu_window, text="Main Menu", relief=RIDGE)
mm_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
# Creation of buttons
mm_timetable_button = ttk.Button(mm_frame, text="My Timetable", width=500, command=self.test)
mm_timetable_button.grid(row=1, column=1)
mm_homework_button = ttk.Button(mm_frame, text="My Homework", width=500, command=self.test)
mm_homework_button.grid(row=1, column=2)
mm_classes_button = ttk.Button(mm_frame, text="My Classes", width=500, command=self.test)
mm_classes_button.grid(row=1, column=3)
def my_timetable(self):
self.timetable_window = Tk()
self.timetable_window.title(self.username.get() + "'s Timetable")
tt_frame = LabelFrame(self.timetabel_window, text="Timetable", relief=RIDGE)
tt_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
def my_homework(self):
self.
program = Gui()
program.window.mainloop()
need to add a few more functions and connect this to my database python file, but im not too sure where the code is breaking (also thanks for the reply)
nice looking code.
So you are looking too write it too your database file?
RE: Tkinter in python - Thanu - 03-25-2019
(03-24-2019, 02:55 PM)darkninja1980 Wrote: (03-24-2019, 05:31 AM)Thanu Wrote: Code: from tkinter import *
from tkinter import ttk
from tkinter import messagebox as ms
import datetime
class Gui:
def __init__(self):
self.window = Tk()
self.window.title("School Life!")
self.window.geometry("1024x768")
self.window.configure(background="azure")
self.username = StringVar()
self.password = StringVar()
self.n_username = StringVar()
self.n_password = StringVar()
self.role = IntVar()
self.homescreen()
def menubar(self):
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def test(self):
print("It works")
def na_homescreen_del(self):
self.window.destroy()
self.new_account_gui()
def mm_homescreen_del(self):
self.window.destroy()
self.mainmenu()
def tt_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_timetable()
def hw_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_homework()
def hs_newaccount_del(self):
self.new_acc_window.destroy()
self.homescreen()
def new_account_gui(self):
self.new_acc_window = Tk()
self.new_acc_window["padx"] = 5
self.new_acc_window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "na" stands for 'new account'
header_label = Label(self.new_acc_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X, side=TOP)
na_frame = LabelFrame(self.new_acc_window, text="Create A New Account", relief=RIDGE)
na_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
na_username_label = Label(na_frame, text="Username")
na_username_label.grid(row=2, column=2, sticky=W, pady=3)
na_password_label = Label(na_frame, text="Password")
na_password_label.grid(row=3, column=2, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their new user credentials
na_username_entry = Entry(na_frame, width=30, textvariable=self.n_username)
na_username_entry.grid(row=2, column=3, sticky=W, pady=3)
na_password_entry = Entry(na_frame, width=30, textvariable=self.n_password, show="*")
na_password_entry.grid(row=2, column=3, sticky=W, pady=3)
# Creation of buttons
na_login_button = ttk.Button(na_frame, text="Go Back", width=10, command=self.hs_newaccount_del())
na_login_button.grid(row=4, column=2)
na_create_new_button = ttk.Button(na_frame, text="Create New Account", width=12, command=self.test) # This needs to change to put the user inputs as the username and password.
na_create_new_button.grid(row=4, column=3)
na_quit_button = ttk.Button(na_frame, text="Quit", width=12, command=self.new_acc_window.quit)
na_quit_button.grid(row=4, column=3)
na_current_date = str(datetime.datetime.now().date)
na_date_entry = Entry(na_frame, width=10, textvariable=na_current_date)
na_date_entry.grid(row=0, column=10)
def homescreen(self):
self.window["padx"] = 5
self.window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "hs" stands for 'home screen'
header_label = Label(self.window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
hs_frame = LabelFrame(self.window, text="Log In", labelanchor=N, relief=RIDGE)
hs_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
hs_username_label = Label(hs_frame, text="Username", font=("", 15))
hs_username_label.grid(row=25, column=23, sticky=W, pady=3)
hs_password_label = Label(hs_frame, text="Password", font=("", 15))
hs_password_label.grid(row=26, column=23, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their log in details
hs_username_entry = Entry(hs_frame, width=15, textvariable=self.username)
hs_username_entry.grid(row=25, column=24, sticky=W, pady=3)
hs_password_entry = Entry(hs_frame, width=15, textvariable=self.password, show="*")
hs_password_entry.grid(row=26, column=24, sticky=W, pady=3)
# Creation of buttons
hs_login_button = ttk.Button(hs_frame, text="Sign In", width=30, command=self.mm_homescreen_del())
hs_login_button.grid(row=30, column=19)
hs_create_new_button = ttk.Button(hs_frame, text="Create New Account", width=30, command=self.na_homescreen_del())
hs_create_new_button.grid(row=30, column=22)
hs_quit_button = ttk.Button(hs_frame, text="Quit", width=40, command=self.window.quit)
hs_quit_button.grid(row=30, column=25)
hs_date_label = Label(hs_frame, text=datetime.datetime.now().strftime('%d-%m-%Y'))
hs_date_label.grid(row=1, column=0)
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def mainmenu(self):
self.mainmenu_window = Tk()
self.mainmenu_window["padx"] = 5
self.mainmenu_window["pady"] = 5
header_label = Label(self.mainmenu_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
mm_frame = LabelFrame(self.mainmenu_window, text="Main Menu", relief=RIDGE)
mm_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
# Creation of buttons
mm_timetable_button = ttk.Button(mm_frame, text="My Timetable", width=500, command=self.test)
mm_timetable_button.grid(row=1, column=1)
mm_homework_button = ttk.Button(mm_frame, text="My Homework", width=500, command=self.test)
mm_homework_button.grid(row=1, column=2)
mm_classes_button = ttk.Button(mm_frame, text="My Classes", width=500, command=self.test)
mm_classes_button.grid(row=1, column=3)
def my_timetable(self):
self.timetable_window = Tk()
self.timetable_window.title(self.username.get() + "'s Timetable")
tt_frame = LabelFrame(self.timetabel_window, text="Timetable", relief=RIDGE)
tt_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
def my_homework(self):
self.
program = Gui()
program.window.mainloop()
need to add a few more functions and connect this to my database python file, but im not too sure where the code is breaking (also thanks for the reply)
nice looking code.
So you are looking too write it too your database file?
Yes I have partially written my database code. But I am trying to get the GUI to work but I keep getting errors. Whenever I try to run the program, it automatically runs the functions that are supposed to be bound to the buttons, hence I get all sorts of errors. I am not sure where in my code this is coming from, so if someone could kindly point me in the right direction, that would be great!
RE: Tkinter in python - darkninja1980 - 03-25-2019
(03-25-2019, 02:56 AM)Thanu Wrote: (03-24-2019, 02:55 PM)darkninja1980 Wrote: (03-24-2019, 05:31 AM)Thanu Wrote: Code: from tkinter import *
from tkinter import ttk
from tkinter import messagebox as ms
import datetime
class Gui:
def __init__(self):
self.window = Tk()
self.window.title("School Life!")
self.window.geometry("1024x768")
self.window.configure(background="azure")
self.username = StringVar()
self.password = StringVar()
self.n_username = StringVar()
self.n_password = StringVar()
self.role = IntVar()
self.homescreen()
def menubar(self):
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def test(self):
print("It works")
def na_homescreen_del(self):
self.window.destroy()
self.new_account_gui()
def mm_homescreen_del(self):
self.window.destroy()
self.mainmenu()
def tt_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_timetable()
def hw_mainmenu_del(self):
self.mainmenu_window.destroy()
self.my_homework()
def hs_newaccount_del(self):
self.new_acc_window.destroy()
self.homescreen()
def new_account_gui(self):
self.new_acc_window = Tk()
self.new_acc_window["padx"] = 5
self.new_acc_window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "na" stands for 'new account'
header_label = Label(self.new_acc_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X, side=TOP)
na_frame = LabelFrame(self.new_acc_window, text="Create A New Account", relief=RIDGE)
na_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
na_username_label = Label(na_frame, text="Username")
na_username_label.grid(row=2, column=2, sticky=W, pady=3)
na_password_label = Label(na_frame, text="Password")
na_password_label.grid(row=3, column=2, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their new user credentials
na_username_entry = Entry(na_frame, width=30, textvariable=self.n_username)
na_username_entry.grid(row=2, column=3, sticky=W, pady=3)
na_password_entry = Entry(na_frame, width=30, textvariable=self.n_password, show="*")
na_password_entry.grid(row=2, column=3, sticky=W, pady=3)
# Creation of buttons
na_login_button = ttk.Button(na_frame, text="Go Back", width=10, command=self.hs_newaccount_del())
na_login_button.grid(row=4, column=2)
na_create_new_button = ttk.Button(na_frame, text="Create New Account", width=12, command=self.test) # This needs to change to put the user inputs as the username and password.
na_create_new_button.grid(row=4, column=3)
na_quit_button = ttk.Button(na_frame, text="Quit", width=12, command=self.new_acc_window.quit)
na_quit_button.grid(row=4, column=3)
na_current_date = str(datetime.datetime.now().date)
na_date_entry = Entry(na_frame, width=10, textvariable=na_current_date)
na_date_entry.grid(row=0, column=10)
def homescreen(self):
self.window["padx"] = 5
self.window["pady"] = 5
# Title and creation of label frame to contain widgets ----- "hs" stands for 'home screen'
header_label = Label(self.window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
hs_frame = LabelFrame(self.window, text="Log In", labelanchor=N, relief=RIDGE)
hs_frame.pack(side=LEFT, fill=BOTH, expand=True)
# Creation of labels
hs_username_label = Label(hs_frame, text="Username", font=("", 15))
hs_username_label.grid(row=25, column=23, sticky=W, pady=3)
hs_password_label = Label(hs_frame, text="Password", font=("", 15))
hs_password_label.grid(row=26, column=23, sticky=W, pady=3)
# Creation of entry widgets for the user to enter their log in details
hs_username_entry = Entry(hs_frame, width=15, textvariable=self.username)
hs_username_entry.grid(row=25, column=24, sticky=W, pady=3)
hs_password_entry = Entry(hs_frame, width=15, textvariable=self.password, show="*")
hs_password_entry.grid(row=26, column=24, sticky=W, pady=3)
# Creation of buttons
hs_login_button = ttk.Button(hs_frame, text="Sign In", width=30, command=self.mm_homescreen_del())
hs_login_button.grid(row=30, column=19)
hs_create_new_button = ttk.Button(hs_frame, text="Create New Account", width=30, command=self.na_homescreen_del())
hs_create_new_button.grid(row=30, column=22)
hs_quit_button = ttk.Button(hs_frame, text="Quit", width=40, command=self.window.quit)
hs_quit_button.grid(row=30, column=25)
hs_date_label = Label(hs_frame, text=datetime.datetime.now().strftime('%d-%m-%Y'))
hs_date_label.grid(row=1, column=0)
menu_bar = Menu(self.window)
options_menu = Menu(menu_bar, tearoff=0)
options_menu.add_command(label="Log Out", command=self.test)
options_menu.add_command(label="Quit", command=self.window.quit)
menu_bar.add_cascade(label="Options", menu=options_menu)
def mainmenu(self):
self.mainmenu_window = Tk()
self.mainmenu_window["padx"] = 5
self.mainmenu_window["pady"] = 5
header_label = Label(self.mainmenu_window, text="The School Life App!", font=("", 30, "bold"))
header_label.pack(fill=X)
mm_frame = LabelFrame(self.mainmenu_window, text="Main Menu", relief=RIDGE)
mm_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
# Creation of buttons
mm_timetable_button = ttk.Button(mm_frame, text="My Timetable", width=500, command=self.test)
mm_timetable_button.grid(row=1, column=1)
mm_homework_button = ttk.Button(mm_frame, text="My Homework", width=500, command=self.test)
mm_homework_button.grid(row=1, column=2)
mm_classes_button = ttk.Button(mm_frame, text="My Classes", width=500, command=self.test)
mm_classes_button.grid(row=1, column=3)
def my_timetable(self):
self.timetable_window = Tk()
self.timetable_window.title(self.username.get() + "'s Timetable")
tt_frame = LabelFrame(self.timetabel_window, text="Timetable", relief=RIDGE)
tt_frame.pack(side=LEFT, fill=BOTH, expand=TRUE)
def my_homework(self):
self.
program = Gui()
program.window.mainloop()
need to add a few more functions and connect this to my database python file, but im not too sure where the code is breaking (also thanks for the reply)
nice looking code.
So you are looking too write it too your database file?
Yes I have partially written my database code. But I am trying to get the GUI to work but I keep getting errors. Whenever I try to run the program, it automatically runs the functions that are supposed to be bound to the buttons, hence I get all sorts of errors. I am not sure where in my code this is coming from, so if someone could kindly point me in the right direction, that would be great!
maybe read this example.
https://www.tutorialspoint.com/csharp/csharp_file_io.htm
RE: Tkinter in python - Thanu - 03-25-2019
(03-25-2019, 04:08 AM)darkninja1980 Wrote: (03-25-2019, 02:56 AM)Thanu Wrote: (03-24-2019, 02:55 PM)darkninja1980 Wrote: nice looking code.
So you are looking too write it too your database file?
Yes I have partially written my database code. But I am trying to get the GUI to work but I keep getting errors. Whenever I try to run the program, it automatically runs the functions that are supposed to be bound to the buttons, hence I get all sorts of errors. I am not sure where in my code this is coming from, so if someone could kindly point me in the right direction, that would be great!
maybe read this example.
https://www.tutorialspoint.com/csharp/csharp_file_io.htm
That's C# not python , I have no knowledge of C# at all.
RE: Tkinter in python - darkninja1980 - 03-25-2019
(03-25-2019, 10:08 AM)Thanu Wrote: (03-25-2019, 04:08 AM)darkninja1980 Wrote: (03-25-2019, 02:56 AM)Thanu Wrote: Yes I have partially written my database code. But I am trying to get the GUI to work but I keep getting errors. Whenever I try to run the program, it automatically runs the functions that are supposed to be bound to the buttons, hence I get all sorts of errors. I am not sure where in my code this is coming from, so if someone could kindly point me in the right direction, that would be great!
maybe read this example.
https://www.tutorialspoint.com/csharp/csharp_file_io.htm
That's C# not python , I have no knowledge of C# at all.
each programming Language have the same concepts like arrays, loops , etc.
|