Currently, I'm preforming the following code to delete the child widgets on the gui
for child in infoFrame.winfo_children():
child.destroy()
However, the gui will not add another child to the gui. For example, neither lines of the following code
people.place(in_ = gui, x = 1, y = 1, width = 422, height = 449)
people.grid(row = 0, column = 0)
place a label on the gui. I'm using the following code to create the label
people = Label(text = "Default", fg = "black", bg = "white")
EDIT I was asked to add my gui code, so here it is:
def initializeGui(name = "Default"):
GUI = Tk()
GUI.geometry("423x450+200+200")
GUI.title(name)
return GUI
def buttonAnswers(): #This is what I'm focusing on
gui.title("Answers")
for child in gui.winfo_children():
child.destroy()
return True
people = Label(text = "Default", fg = "black", bg = "white")
#people.place(in_ = gui, x = 1, y = 1, width = 422, height = 449)
people.grid(row = 0, column = 0)
def buttonTest(): #This will be the same as the button above but will open a different gui
gui.title("Test")
for child in gui.winfo_children():
child.destroy()
return True
question = Label(text = "Do you want to see the Answers or take the Test?", fg = "black", bg = "white")
question.grid(row = 0, column = 1)
checkAns = Button(gui, text = "Answers", command = buttonAnswers, fg = "black", width=10)
checkAns.grid(row = 1, column = 0)
gui = initializeGui("School Test")
label = Label(text = "Do you want to see the Answers or take the Test?", fg = "black", bg = "white")
label.grid(row = 0, column = 1)
answers = Button(gui, text = "Answers", command = buttonAnswers, fg = "black", width=10)
questions = Button(gui, text = "Test", command = buttonTest, fg = "black", width=10)
answers.grid(row = 1, column = 0)
questions.grid(row = 1, column = 2)`
The solution to the issue was the following:
def buttonAnswers(): #This is what I'm focusing on
gui.title("Answers")
for child in gui.winfo_children():
child.destroy()
return True
people = Label(text = "Default", fg = "black", bg = "white")
#people.place(in_ = gui, x = 1, y = 1, width = 422, height = 449)
people.grid(row = 0, column = 0)
contained a return True underneath the for loop, preventing the program from continuing. As such, removing the return True allowed the program to continue with the script and add the other children to the form.
def buttonAnswers(): #This is what I'm focusing on
gui.title("Answers")
for child in gui.winfo_children():
child.destroy()
people = Label(text = "Default", fg = "black", bg = "white")
#people.place(in_ = gui, x = 1, y = 1, width = 422, height = 449)
people.grid(row = 0, column = 0)
You have a return statement after you destroy the widgets but before you add any new widgets. The code to add the new widgets is never getting executed.
Related
This is my first venture into tkinter programming, so far I have the following code that increases or decreases a number by pressing either button. As you may notice I have started adding an update definition that I'd like to update a results table with the label value each time a button is pressed. I've recently found the lambda expression to add two commands to each button press but can't find an example to build the list:
import tkinter as tk
window = tk.Tk()
def increase():
value = int(lbl_value["text"])
lbl_value["text"] = f"{value + 1}"
def decrease():
value = int(lbl_value["text"])
lbl_value["text"] = f"{value - 1}"
def update():
result_table = []
window.rowconfigure(0, minsize = 100, weight = 1)
window.columnconfigure([0,1,2], minsize = 100, weight = 1)
btn_decrease = tk.Button(master = window, text = "-", command = lambda:[decrease(), update()], bg = 'red', fg = 'white')
btn_decrease.grid(row = 0, column = 0, sticky = "nsew")
lbl_value = tk.Label(master = window, text = "0")
lbl_value.grid(row = 0, column = 1)
btn_increase = tk.Button(master = window, text = "+", command = lambda:[increase(), update()], bg = 'green', fg = 'white')
btn_increase.grid(row = 0, column = 2, sticky = "nsew")
window.mainloop()
, bg = 'black', fg = 'white')
btn_decrease.grid(row = 0, column = 0, sticky = "nsew")
lbl_value = tk.Label(master = window, text = "0")
lbl_value.grid(row = 0, column = 1)
btn_increase = tk.Button(master = window, text = "+", command = increase, bg = 'red', fg = 'white')
btn_increase.grid(row = 0, column = 2, sticky = "nsew")
window.mainloop()
I'd like to add a graph of the count to the display ultimately. Any help greatly appreciated.
Matt
The problem is idk how to make a vertical style multiple choice question quiz asking for the capitals of countries and allowing for a multiple choice to choose the correct country. I currently have made a welcome home frame for asking for the users name and age to enter my quiz and I'm stuck on how to write the code for the next frame. I have attached screenshots below at how I want the multiple choice quiz to be similar to my first frame where the question and multiple choice is underneath the black and white title label named Quiz Question, I want to try and make a second frame containing the multiple choice question that can be accessed from a radio button named next from the first frame code I have shown below.
from tkinter import*
from tkinter import ttk
class CapitalQuiz:
def __init__(self,parent):
'''Widgets for Welcome Frame'''
self.Welcome = Frame(parent)
self.Welcome.grid(row=0, column=0)
self.TitleLabel = Label(self.Welcome, text = "Welcome to Capital Quiz",
bg = "black", fg = "white", width = 20, padx = 30, pady = 10, font = ("Time", '14', "bold italic"))
self.TitleLabel.grid(columnspan = 2)
#Name and Age Labels
self.NameLabel = Label(self.Welcome, text = "Name", anchor = W,
fg = "black", width = 10, padx = 30, pady = 10, font = ("Time", '12', "bold italic"))
self.NameLabel.grid(row = 2, column = 0)
self.AgeLabel = Label(self.Welcome, text = "Age", anchor = W,
fg = "black", width = 10, padx = 30, pady = 10, font = ("Time", '12', "bold italic"))
self.AgeLabel.grid(row=3, column = 0)
#Name and Age Entry
self.NameEntry = ttk.Entry(self.Welcome, width = 20)
self.NameEntry.grid(row=2, column = 1, columnspan = 2)
self.AgeEntry = ttk.Entry(self.Welcome, width = 20)
self.AgeEntry.grid(row = 3, column = 1)
#Difficulty level label and radio buttons
self.WarningLabel = Label(self.Welcome, text = "", anchor=W, fg = "red", width = 20, padx = 30, pady = 10)
self.WarningLabel.grid(row=4, columnspan = 2)
self.DifficultyLabel = Label(self.Welcome, text = "Choose Difficulty level", anchor=W, fg = "black", width = 10, padx = 30, pady = 10, font = ("Time", '12',"bold italic"))
self.DifficultyLabel.grid(row=5, column = 0)
self.difficulty = ["Easy", "Medium", "Hard"]
self.diff_lvl = StringVar()
self.diff_lvl.set(0)
self.diff_btns = [ ]
for i in range(len(self.difficulty)):
self.rb = Radiobutton(self.Welcome, variable = self.diff_lvl, value = i, text = self.difficulty[i], anchor = W, padx = 50, width = "5", height = "2")
self.diff_btns.append(self.rb)
self.rb.grid(row = i+6, column = 0, sticky = W)
'''Widgets for Question Frame'''
self.Questions = Frame(parent)
self.QuestionsLabel = Label(self.Questions, text = "Quiz Questions", bg = "black", fg = "white", width = 20, padx = 30, pady = 10,font = ("Time", '14', "bold italic"))
self.QuestionsLabel.grid(columnspan = 2)
self.HomeButton = ttk.Button(self.Questions, text = 'Home', command = self.show_Welcome)
self.HomeButton.grid(row = 8, column = 1)
'''A Method that removes Questions Frame'''
def show_Welcome(self):
self.Questions.grid_remove()
self.Welcome.grid()
def show_Questions(self):
try:
if self.NameEntry.get() == "":
self.WarningLabel.configure(text = "Please enter name")
self.NameEntry.focus()
elif self.NameEntry.get().issalpha() == False:
self.WarningLabel.configure(text = "Please enter text")
self.NameEntry.delete(0, END)
self.NameEntry.focus()
elif self.AgeEntry.get() == "":
self.WarningLabel.configure(text = "Please enter age")
self.AgeEntry.focus()
elif int(self.AgeEntry.get()) > 12:
self.WarningLabel.configure(text = "You are too old!")
self.AgeEntry.delete(0, END)
self.AgeEntry.focus()
elif int(self.AgeEntry.get()) < 0:
self.WarningLabel.configure(text = "You are too old")
self.AgeEntry.delete(0, END)
self.AgeEntry.focus()
elif int(self.AgeEntry.get()) < 7:
self.WarningLabel.configure(text = "You are too young")
self.AgeEntry.delete(0, END)
self.AgeEntry.focus()
else:
self.Welcome.grid_remove()
self.Questions.grid()
except ValueError:
self.WarningLabel.configure(text = "Please enter a number")
self.AgeEntry.delete(0, END)
self.AgeEntry.focus()
I reviewed your code and your requirements for your program CapitalQuiz. I made some changes in code you attach. I change the method of the showing Titletext because according to your method you have to create label everytime to show Titletext when you switch the frames between because the TitleLabel is the part of the Welcome frame
self.TitleLabel = Label(self.Welcome, text = "Welcome to Capital
Quiz",bg = "black", fg = "white", width = 20, padx = 30, pady = 10,
font = ("Time", '14', "bold italic"))
self.TitleLabel.grid(columnspan = 2)
I remove it from Welcome frame & pack it in parent with Welcome frame so now we only have to change the frame to QuestionFrame to swich between. Also i created function called setTitleLabelText to set Titlelabel text using textvarible anytime & anywhere.
I wrote the method to switch to Questions Frame and change Title to "Questions". For switch to Questions frame we a need button but you had not created so i create one called Start Quiz in Welcome Frame. I have not write the code to load a question i have only write the code to switch to a questions frame and from questions frame to Welcomr frame.
Here's the code.
from tkinter import*
from tkinter import ttk
class CapitalQuiz:
def __init__(self,parent):
'''Title Label. I remove it from welcome frame cause ,
when we change the frame we have to again create another label to show other title which is make program slow
I pack it in parent window with welcome frame and asign tkinter StringVar so we can change it anytime
from anywhere with function'''
self.Titletext = StringVar()
self.TitleLabel = Label(parent, textvariable=self.Titletext,
bg = "black", fg = "white", width = 20, padx = 30, pady = 10, font = ("Time", '14', "bold italic"))
self.TitleLabel.pack(side="top",fill="x")
#Function to set TitleLabelText
self.setTitleLabeltext("Welcome to CapitalQuiz")
#Welcome Frame
self.Welcome = Frame(parent)
self.Welcome.pack(fill="both")
'''Widgets for Welcome Frame'''
#Name and Age Labels
self.NameLabel = Label(self.Welcome, text = "Name", anchor = W,
fg = "black", width = 10, padx = 30, pady = 10, font = ("Time", '12', "bold italic"))
self.NameLabel.grid(row = 2, column = 0)
self.AgeLabel = Label(self.Welcome, text = "Age", anchor = W,
fg = "black", width = 10, padx = 30, pady = 10, font = ("Time", '12', "bold italic"))
self.AgeLabel.grid(row=3, column = 0)
#Name and Age Entry
self.NameEntry = ttk.Entry(self.Welcome, width = 20)
self.NameEntry.grid(row=2, column = 1, columnspan = 2)
self.AgeEntry = ttk.Entry(self.Welcome, width = 20)
self.AgeEntry.grid(row = 3, column = 1)
#Difficulty level label and radio buttons
self.WarningLabel = Label(self.Welcome, text = "", anchor=W, fg = "red", width = 20, padx = 30, pady = 10)
self.WarningLabel.grid(row=4, columnspan = 2)
self.DifficultyLabel = Label(self.Welcome, text = "Choose Difficulty level", anchor=W, fg = "black", width = 10, padx = 30, pady = 10, font = ("Time", '12',"bold italic"))
self.DifficultyLabel.grid(row=5, column = 0)
self.difficulty = ["Easy", "Medium", "Hard"]
self.diff_lvl = StringVar()
self.diff_lvl.set(0)
self.diff_btns = [ ]
for i in range(len(self.difficulty)):
self.rb = Radiobutton(self.Welcome, variable = self.diff_lvl, value = i, text = self.difficulty[i], anchor = W, padx = 50, width = "5", height = "2")
self.diff_btns.append(self.rb)
self.rb.grid(row = i+6, column = 0, sticky = W)
'''A button to switch to Questions Frame'''
row = len(self.difficulty)
self.StartQuizButton = ttk.Button(self.Welcome, text = 'Start Quiz',command=self.show_Questions)
self.StartQuizButton.grid(row = row+6, column = 0,pady=5,columnspan=3)
'''Widgets for Question Frame'''
self.Questions = Frame(parent)
self.QuestionsLabel = Label(self.Questions, text = "Quiz Questions", bg = "black", fg = "white", width = 20, padx = 30, pady = 10,font = ("Time", '14', "bold italic"))
self.QuestionsLabel.pack(fill="both")
self.QuestionsLabel.pack_forget()
self.HomeButton = ttk.Button(self.Questions, text = 'Home',command=self.showWelcomeFrame)
self.HomeButton.grid(row = 8, column = 0,columnspan=3)
# '''A Method that removes Questions Frame'''
def setTitleLabeltext(self,text):
# This method can be use in class multiple times so,
# we dont have to make individual function everytime to show TitleText
self.Titletext.set(text)
def showQuestionFrame(self):
self.Welcome.pack_forget()
self.Questions.pack(fill="both")#Here we have to specify the pack values again becuase we called pack_forget befor
self.setTitleLabeltext("Questions")
def showWelcomeFrame(self):
self.Questions.pack_forget()
self.Welcome.pack(fill="both")#Here we have to specify the pack values again becuase we called pack_forget before
self.setTitleLabeltext("Welcome to CapitalQuiz")
self.NameEntry.delete(0,"end")
self.AgeEntry.delete(0,"end")
def show_Questions(self):
try:
if self.NameEntry.get() == "":
self.WarningLabel.configure(text = "Please enter name")
self.NameEntry.focus()
elif self.NameEntry.get().isalpha() == False:
self.WarningLabel.configure(text = "Please enter text")
self.NameEntry.delete(0, END)
self.NameEntry.focus()
elif self.AgeEntry.get() == "":
self.WarningLabel.configure(text = "Please enter age")
self.AgeEntry.focus()
elif int(self.AgeEntry.get()) > 12:
self.WarningLabel.configure(text = "You are too old!")
self.AgeEntry.delete(0, END)
self.AgeEntry.focus()
elif int(self.AgeEntry.get())
I have a program running that is having issues when the timer runs. Every time "start" is hit, the application crashes. Any thoughts?
##-- Imports --##
import time
import openpyxl as xl
from Tkinter import *
##-- Classes --##
class App(Frame):
def startTimer(self):
self.check = True
self.now = time.strftime("%H:%M:%S")
while self.check == True:
self.timer.configure(text = self.now)
time.sleep(1)
def initUI(self):
self.parent.title("Emma's Time Manager")
self.pack(fill = BOTH, expand = 1)
def initWidget(self):
##Create button definitions##
self.buttonwidth = 12
self.quit = Button(self, text = "Quit", comman = self.quit, width = self.buttonwidth)
self.newClient = Button(self, text = "Add Client", command = lambda:self.newClientFunc(), width = self.buttonwidth)
self.timeStart = Button(self, text = "Start", command = lambda:self.startTimer(), width = self.buttonwidth)
self.timeEnd = Button(self, text = "End", command = lambda:self.endTimer(), width = self.buttonwidth)
self.saveBut = Button(self, text = "Save", command = lambda:self.saveFunc(), width = self.buttonwidth)
self.viewClient = Button(self, text = "View Client", command = lambda:self.viewCliFunc(), width = self.buttonwidth)
##Create lable definitions##
self.timer = Label(self, text = "00:00:00") ##self.timer used as display for timer##
##Create the listbox for Client Selection##
self.wb = xl.load_workbook("clients.xlsx")
self.clientNames = self.wb.get_sheet_names()
self.clivar = StringVar(self)
self.clivar.set(self.clientNames[0])
self.clilist = apply(OptionMenu, (self, self.clivar) + tuple(self.clientNames))
##Create Entry Box to describe work information##
self.info = Entry(self, width = 50)
##Create GUI for widgets##
self.clilist.grid(row = 0, column = 0)
self.timer.grid(row = 0, column = 1)
self.timeStart.grid(row = 0, column = 2)
self.timeEnd.grid(row = 0, column = 3)
self.info.grid(row = 1, column = 0, columnspan = 4)
self.newClient.grid(row = 2, column = 0)
self.viewClient.grid(row = 2, column = 1)
self.saveBut.grid(row = 2, column = 2)
self.quit.grid(row = 2, column = 3)
def __init__(self, parent):
Frame.__init__(self, parent, background = "light blue")
self.parent = parent
self.initUI()
self.initWidget()
def main():
try:
xl.load_workbook("clients.xlsx")
except:
temp = xl.Workbook()
temp.save("clients.xlsx")
temp.remove_sheet(temp.get_sheet_by_name("Sheet"))
root = Tk()
bob = App(root)
root.mainloop()
main()
Please note that most of the program is not yet finished. I just cannot seem to get this timer to run properly.
Looks like you have no way out of your while loop. You'll either need to set self.check to False, or break out of the loop.
while self.check == True:
self.timer.configure(text = self.now)
time.sleep(1)
I've seen how to check for a win on tic tac toe games, but I am using images and I can't seem to figure out how. I thought of using if statements and having 3 buttons equal the image that is shown, but that doesn't seem to work. Any ideas?
from tkinter import*
#Window stuff
window = Tk()
window.title("Tic Tac Toe")
window.configure(background = "black")
window.geometry("400x400")
#Variables
global clickable
playerXturn = True
#Display X or O
def buttonClicked(c) :
global playerXturn
if playerXturn == True :
buttonList[c]["image"] = picX
playerXturn = False
labelTurn ["text"] = "O's turn"
elif clickable[c] == "" :
buttonList[c]["image"] = picO
playerXturn = True
labelTurn ["text"] = "X's turn"
#Check for a win
if button1 == picX and button2 == picX and button3 == picX:
print("r")
#Images
picX = PhotoImage (file = "x.gif")
picO = PhotoImage (file = "o.gif")
picBlank = PhotoImage (file = "sw.gif")
#Buttons
button1 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(0))
button1.grid (row = 0, column = 0)
#button1["state"] = DISABLED
button2 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(1))
button2.grid (row = 0, column = 1)
#button2["state"] = DISABLED
button3 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(2))
button3.grid (row = 0, column = 2)
#button3["state"] = DISABLED
button4 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(3))
button4.grid (row = 1, column = 0)
#button4["state"] = DISABLED
button5 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(4))
button5.grid (row = 1, column = 1)
#button5["state"] = DISABLED
button6 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(5))
button6.grid (row= 1, column = 2)
#button6["state"] = DISABLED
button7 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(6))
button7.grid (row = 2, column = 0)
#button7["state"] = DISABLED
button8 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(7))
button8.grid (row = 2, column = 1)
#button8["state"] = DISABLED
button9 = Button (window, text = "", image = picBlank, command = lambda: buttonClicked(8))
button9.grid (row = 2, column = 2)
#button9["state"] = DISABLED
#Labels
labelTurn = Label (window, text = "",)
labelTurn.grid (row = 4, column = 4)
#Lists
buttonList = [button1, button2, button3, button4, button5, button6, button7, button8, button9]
clickable = ["", "", "", "", "", "", "", "", ""]
window.mainloop()
You can use a 2-Dimentional list to store the values of the buttons ("X", "O" or None). After that you should check the rows, columns and diagonals.
List example:
table = [[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]
You can do the check in the main loop, but you can also do the check in each click handler so the unnecessary CPU work would be saved.
After Creating the list, in the checking function you can use implementations like;
for row in table:
if set(row) == set("X"):
# "X"s win condition
like so...
When i put widgets inside my canvas, the widgets bypass the canvas size. But when I scroll, the canvas won't move.
On top of that, the canvas auto re-sizes when I add more widgets. I thought the canvas isn't supposed to re-size because I already added a scroll bar?
Here's my code:
from tkinter import *
from tkinter import ttk
import mysql.connector
class CanvasScroll:
def on_resize(self,event):
self.canvas.config(width = 1185, height = 530)
def add_crew(self):
crewFrame = CrewFrame()
def callback_list(self):
index = self.notebook.index(self.notebook.select()) + 1
self.tmpframe = Try2(self.contentframe, index)
def __init__(self, master):
self.canvas = Canvas(master, width = 1185, height = 530, scrollregion = (0, 0, 1216, 700), bg = 'white', confine = True)
self.canvas.grid(row = 2, column = 0, sticky = 'news')
self.xscroll = ttk.Scrollbar(master, orient = HORIZONTAL, command = self.canvas.xview)
self.xscroll.grid(row = 3, column = 0, sticky = 'we')
self.yscroll = ttk.Scrollbar(master, orient = VERTICAL, command = self.canvas.yview)
self.yscroll.grid(row = 2, column = 1, sticky = 'ns')
self.canvas.config(xscrollcommand = self.xscroll.set, yscrollcommand = self.yscroll.set)
self.canvas.bind("<Configure>", self.on_resize)
self.option = ttk.Frame(master, height = 150, width = 1206)
self.option.grid(row = 0, column = 0, sticky = 'we', columnspan = 5)
self.addicon = PhotoImage(file = 'C:\\Users\\rain\\Desktop\\Fyosh!\\logo\\add.gif').subsample(2,2)
self.btnAdd = ttk.Button(self.option, image = self.addicon, text = 'Add Crew', compound = TOP, command = self.add_crew)
self.btnAdd.grid(row = 0, column = 0, padx = 50, pady = 5)
self.updateicon = PhotoImage(file = 'C:\\Users\\rain\\Desktop\\Fyosh!\\logo\\update.gif').subsample(2,2)
self.btnUpdate = ttk.Button(self.option, image = self.updateicon, text = 'Update Crew', compound = TOP)
self.btnUpdate.grid(row = 0, column = 1, padx = 50)
self.deleteicon = PhotoImage(file = 'C:\\Users\\rain\\Desktop\\Fyosh!\\logo\\delete.gif').subsample(2,2)
self.btnDelete = ttk.Button(self.option, image = self.deleteicon, text = 'Delete Crew', compound = TOP)
self.btnDelete.grid(row = 0, column = 2, padx = 50)
self.reloadicon = PhotoImage(file = 'C:\\Users\\rain\\Desktop\\Fyosh!\\logo\\Refresh.png').subsample(7,7)
self.reloadbtn = ttk.Button(self.option, image = self.reloadicon, command = self.callback_list, text = 'Load List', compound = TOP)
self.reloadbtn.grid(row = 0, column = 3, padx = 50)
self.tabframe = ttk.Frame(master, height = 20)
self.tabframe.grid(row = 1, sticky = 'we')
self.notebook = ttk.Notebook(self.tabframe)
self.notebook.grid(row = 0, column = 0, sticky = 'we')
db = mysql.connector.connect(user = 'root', password = '', host = 'localhost', database = 'fat2x_payroll')
cursor = db.cursor()
ships = ("SELECT * from tbl_shiplist")
try:
cursor.execute(ships)
result = cursor.fetchall()
self.tab = {}
for row in result:
self.tab[row[0]] = {
"shipname": ttk.Frame(self.notebook)
}
self.notebook.add(self.tab[row[0]]["shipname"], text = row[1])
db.close()
except:
messagebox.showinfo("alert", "ship list error")
self.canvas.label = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 0)
self.canvas.label1 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 1)
self.canvas.label2 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 2)
self.canvas.label3 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 3)
self.canvas.label4 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 4)
self.canvas.label5 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 5)
self.canvas.label6 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 6)
self.canvas.label7 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 7)
self.canvas.label8 = ttk.Label(self.canvas, text = "hahahahahha").grid(column = 8)
def start():
master = Tk()
master.geometry("1206x690+10+10")
master.resizable(0,0)
master.title("Crew Panel")
canvasScroll = CanvasScroll(master)
if __name__ == "__main__":
start()
The canvas can only scroll objects that are embedded on the canvas. In the case of widgets, that means that you've called the create_window method of the canvas for the widgets you want to be affected by the scrollbar.
If you want to use grid to organize widgets, and you want those widgets to be in a scrollable container, the usual method is to put those widgets inside a frame, and then add the frame to the canvas with create_window. You can see an example of this technique in this answer: https://stackoverflow.com/a/3092341/7432
As for the auto-resize, this behavior is completely unrelated to using a scrollbar. If you use grid or pack on a widget, the parent will always resize unless you've turned geometry propagation off. It doesn't matter if it's a Canvas or a Frame or a Toplevel, or any other class of widget.