I have the code below: Then, I got the error below: TypeError: generatecode() takes 0 positional arguments but 1 was given So, how can I solve the error? Answer When you call a method on a class (such as generatecode() in this case), Python automatically passes self as the first argument to the function. So when you call self.my_func(), it’s
Tag: tkinter
Python equivalent for C#’s generic List
I am creating a simple GUI program to manage priorities. I have successfully managed to add functionality to add an item to the listbox. Now I want to add the item to the something what is known as List<> in C#. Does such a thing exist in Python? For instance, in C#, to add an item to the listview I
Border colours of canvases (tkinter)
I need help with changing the border colour of a canvas in tkinter This is my code: I have tried: Answer You can use highlightbackground option to change color of border highlight ring(which is also a border-like thing, but is separate from the actual border). (correction, thanks to Bryan Oakley’s comment ) To change border highlight ring thickness, you should
Unable to Load an Image from an URL at TKinter
My goal is to display an JPG image from an URL using tkinter python. This is the stackoverflow link that I used as a reference. But when I try to run the code, I have received a bunch of error such as: KeyError: b’R0l……. AttributeError: ‘PhotoImage’ object has no attribute ‘_PhotoImage__photo’ Does anyone have the solution to this? This is
How do we dynamically change the text in label widget of Tkinter according to the change of subscribed topic message?
I wanted to change the text of my label according to the topic message to which my node subscribes. But the problem is that the text in the label is not changing with the change of topic message. A portion of my code is given below:(I used the code to dynamically change the text in the label from https://bytes.com/topic/python/answers/629499-dynamically-displaying-time-using-tkinter-label) Answer
How to set a tkinter window to a constant size
I’m programming a little game with tkinter and briefly, I’m stuck. I have a kind od starting menu, in which are two buttons and one label. If I just create the frame everything is fine, it has the size 500×500 pixels I want the background not to change when I create the buttons and the labe, but it adapts the
How to get the value of a selected treeview item?
I’ve looked at several posts regarding this and they’ve done the following -The output i get is blank -The output i get is the id, which is practically useless unless somebody can show me how to manipulate it -No output at all i just want to be able to click an item in treeview, and instantly be given the text
Tkinter import filedialog error
I’m trying to use tkinter with python3 to open an image, see here a piece of code : I have installed python3-tk, and I have the demo window when I write in the terminal. I tried several combinations that did not work : gives , gives I tried with _tinker , FileDialog, file_dialog, but I always have “ImportError : cannot
How to have tabs of a ttk Notebook in different rows?
In the below program i have many tabs in a single notebook page. when the number of tabs increases the look changes. So how to put the tabs in different rows As in attached image, I have many tabs in a single row, but I want some tabs say from JJJJ in a below row. How to set tabs in
Tkinter: getting coordinates of a mouse drawn rectangle
Working on the answer of my previous question, I wonder how to get the coordinates of the 4 pixels representing the corners of the rectangle as well as its 2 dimensions ? Answer You can use canvas.bbox(item) to get the coordinates of the bounding box of an item on the canvas. Because your item is a rectangle, the bounding box