Jan-21-2018, 06:40 PM
First off, be warned: I am a hopeless newbie within the realms of python with just shy of two months of experience thus far.
I am making slow progress, however, and normally I can manage working out the bugs and assorted snags if I just put a little work into researching.
In this case, however, I'm somewhat stuck as I cannot wrap my head around what would otherwise appear to be a simple operation.
During the past week it has grown into some variation of 'code blindness'; the further I've been digging, the worse the code has gotten*, so now I turn to you, the good people of python-forum.
I would like to somehow connect 'myVar' to 'button_1', 'button_2' and 'button_3' in the method shown below.
I've made a v1.0 of the program (a weather station that scrapes the web for a forecast and assorted data) which works witout using classes, but then I thought that it would be a good exercise to implement classes. Oh, Icarus.
I've omitted the rest of the code as I don't think it bears relevance, but will upload the entire script if needed, of course; just let me know, please.
Thank you for taking the time to read through this post :)
I am making slow progress, however, and normally I can manage working out the bugs and assorted snags if I just put a little work into researching.
In this case, however, I'm somewhat stuck as I cannot wrap my head around what would otherwise appear to be a simple operation.
During the past week it has grown into some variation of 'code blindness'; the further I've been digging, the worse the code has gotten*, so now I turn to you, the good people of python-forum.
I would like to somehow connect 'myVar' to 'button_1', 'button_2' and 'button_3' in the method shown below.
I've made a v1.0 of the program (a weather station that scrapes the web for a forecast and assorted data) which works witout using classes, but then I thought that it would be a good exercise to implement classes. Oh, Icarus.
I've omitted the rest of the code as I don't think it bears relevance, but will upload the entire script if needed, of course; just let me know, please.
Thank you for taking the time to read through this post :)
from tkinter import * class lbl(object): def __init__(self, pos, txt, row, col, colspan): self.position = pos self.text = txt self.row = row self.column = col self.columnspan = colspan myVar = Label(self.position, self.text) myVar.grid(self.row, self.column, self.columnspan) root = Tk() root.title("Vejrstation 1.0") root.geometry("350x350") #root.resizable(True, True) root.resizable(False, False) label_1 = lbl(root, "temp.", 0, 0, 1) label_2 = lbl(root, "fugt", 0, 1, 1) label_3 = lbl(root, "vind", 0, 2, 1) root.mainloop()* I would supply some of my more horrendous attempts and ideas for the shere comedy value, but let's keep it concise for now, eh? ;)