Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Learning Aids/Tools 2 years ago
Posted on 16 Aug 2022, this text provides information on Learning Aids/Tools related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I've been learning tkinter with the help of a python book. However, the python book is written for python 2 and I'm using python 3. This has generated several errors, and up to now I've been able to fix them, with the aid of other questions here. It is a basic program that shows a window with buttons to play 3 games or to destroy the window. When either of the first two games(rock paper scissors and hangman) are opened, they are supposed to open a Toplevel() that has various buttons that lets you play the game. I haven't written the graphics code for the third game yet. They don't play, though, because of an error: _tkinter.TclError: unknown option "-padding" which I haven't found any detail about online. I understand that the unknown option means that that attribute/keyword doesn't exist in my version of tkinter and python 3. The error lines look like: rpsFrame = Frame(rpsWindow, padding = '3 3 12 12', width = 300)
In case you need it, the error and code are below. (this code doesn't run without additional code) (if you want this code I will add it, but I want to keep this shortish)
Here is the full error traceback:
Exception in Tkinter callback Traceback (most recent call last): File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__ return self.func(*args) File "E:\Python\Python Book\Graphics\Hangman.py", line 149, in gui hmFrame = Frame(hmWindow, padding = "3 3 12 12", width = 300) File "C:\Python34\lib\tkinter\__init__.py", line 2582, in __init__ Widget.__init__(self, master, 'frame', cnf, {}, extra) File "C:\Python34\lib\tkinter\__init__.py", line 2122, in __init__ (widgetName, self._w) + extra + self._options(cnf)) _tkinter.TclError: unknown option "-padding"
Here is the interface code:
from tkinter import * import RockPaperScissors import Hangman import PokerDice root = Tk() root.title("Linux User & Developer's Mega Games Collection") mainframe = Frame(root, height = 200, width = 500) mainframe.pack_propagate(0) mainframe.pack(padx = 5, pady = 5) intro = Label(mainframe, text = """Welcome to Linux User & Developers Mega Microgames Collection. Select one of the following games to play: """) intro.pack(side = TOP) rpsButton = Button(mainframe, text = "Rock, Paper, Scissors", command = RockPaperScissors.gui) rpsButton.pack() hmButton = Button(mainframe, text = "Hangman", command = Hangman.gui) hmButton.pack() pdButton = Button(mainframe, text = "Poker Dice", command = PokerDice REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
There are virtually no differences between tkinter in 2.x vs 3.x, except for the import statements. This is not a 2.x vs 3.x problem.
The padding option is only valid for ttk.Frame, but you're using tkinter.Frame. For the standard tkinter Frame widget you have the padx and pady options.
padding
ttk.Frame
tkinter.Frame
Frame
padx
pady
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.