I am unsure how to structure my python code to follow programming conventions, my teacher told me to start the quiz GUI object at the start instead of with the main, but I am unsure what she means. This is a basic version of my code:
# Import everything from Tkinter module
from tkinter import *
def function():
blajslaksjd
def another_function():
blahblah
# quiz is the tkinter box
# I am going to change the positions to the help menu bar
quiz = Tk()
quiz.geometry('800x800-100+20')
# Menu bar
menu_bar = Menu(quiz)
quiz.config(menu=menu_bar)
help_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Help", menu=help_menu)
# Global variables
variable = 0
# Another variable
question = 0
# Displays the actual question
question_label = Label(text="insert question", font="bold, 13")
# Radio buttons for some functons
option_1 = Radiobutton(quiz, text="text", value=1)
option_2 = Radiobutton(quiz, text="text", value=2)
option_3 = Radiobutton(quiz, text="text", value=3)
option_4 = Radiobutton(quiz, text="text", value=4)
# Label for function
blah = Label(text="Blah")
# Button for function
blahh = Button(quiz, text="BLAHH")
# Display tkinter box
quiz.mainloop()
Is it better if I change it to this? I moved the code which helped define the tkinter box's properties to the top.
# Import everything from Tkinter module
from tkinter import *
# quiz is the tkinter box
quiz = Tk()
quiz.geometry('800x800-100+20')
# Menu bar
menu_bar = Menu(quiz)
quiz.config(menu=menu_bar)
help_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Help", menu=help_menu)
def function():
blajslaksjd
def another_function():
blahblah
# Global variables
variable = 0
# Another variable
question = 0
# Displays the actual question
question_label = Label(text="insert question", font="bold, 13")
# Radio buttons for some functons
option_1 = Radiobutton(quiz, text="text", value=1)
option_2 = Radiobutton(quiz, text="text", value=2)
option_3 = Radiobutton(quiz, text="text", value=3)
option_4 = Radiobutton(quiz, text="text", value=4)
# Label for function
blah = Label(text="Blah")
# Button for function
blahh = Button(quiz, text="BLAHH")
# Display tkinter box
quiz.mainloop()
or this? I moved the code which helped define the tkinter box's properties to the bottom.
# Import everything from Tkinter module
from tkinter import *
def function():
blajslaksjd
def another_function():
blahblah
# Global variables
variable = 0
# Another variable
question = 0
# Displays the actual question
question_label = Label(text="insert question", font="bold, 13")
# Radio buttons for some functons
option_1 = Radiobutton(quiz, text="text", value=1)
option_2 = Radiobutton(quiz, text="text", value=2)
option_3 = Radiobutton(quiz, text="text", value=3)
option_4 = Radiobutton(quiz, text="text", value=4)
# Label for function
blah = Label(text="Blah")
# Button for function
blahh = Button(quiz, text="BLAHH")
# quiz is the tkinter box
quiz = Tk()
quiz.geometry('800x800-100+20')
# Menu bar
menu_bar = Menu(quiz)
quiz.config(menu=menu_bar)
help_menu = Menu(menu_bar, tearoff=0)
menu_bar.add_cascade(label="Help", menu=help_menu)
# Display tkinter box
quiz.mainloop()