मैं अपने स्वयं को सिखाने की कोशिश कर रहा हूं कि टिंकर का उपयोग कैसे करें और मुझे यूट्यूब के माध्यम से एक उपयोगी कोड मिला है कि मैं वास्तव में पूरी तरह से समझ नहीं पा रहा हूं। अगर मैं इसे समझने में मदद कर सकता हूं तो इसकी सराहना करेंगे। बातें मैं के साथ समझ में नहीं आया **टिंकर! फ्रेम को स्विच करने के तरीके को समझना
import tkinter as tk # why not from tkinter import? **
class SampleApp(tk.Tk): tk.TK**
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
# the container is where we'll stack a bunch of frames
# on top of each other, then the one we want visible
# will be raised above the others
container = tk.Frame(self) *
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (StartPage, PageOne, PageTwo):
page_name = F.__name__
frame = F(container, self) **
self.frames[page_name] = frame **
# put all of the pages in the same location;
# the one on the top of the stacking order
# will be the one that is visible.
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("StartPage")
def show_frame(self, page_name):
'''Show a frame for the given page name'''
frame = self.frames[page_name]
frame.tkraise() **
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent) **
self.controller = controller **
label = tk.Label(self, text="This is the start page",
font=TITLE_FONT)
label.pack(side="top", fill="x", pady=10)
button1 = tk.Button(self, text="Go to Page One",
command=lambda: controller.show_frame("PageOne"))
button2 = tk.Button(self, text="Go to Page Two",
command=lambda: controller.show_frame("PageTwo"))
button1.pack()
button2.pack()
क्या आप यूट्यूब लिंक साझा कर सकते हैं? –
@ ब्रायन ओकले यदि आप अभी भी देख रहे थे, तो मैंने [यह] (https://www.youtube.com/watch?v=jBUpjijYtCk) ट्यूटोरियल देखा है जो [मूल प्रश्न] से आपके कोड का उपयोग करता है (http: // stackoverflow.com/a/7557028/3826759), हालांकि वह कहता है कि यह कहां से आया था। यह भी है [यह] (https://pythonprogramming.net/plotting-live-bitcoin-price-data-tkinter-matplotlib/)। –
@double_j: हाँ, मैंने इसे थोड़ी देर पहले पाया, लेकिन धन्यवाद। मैंने आपके द्वारा प्रदान किया गया अन्य लिंक नहीं देखा था। मैंने मूल उत्तर में सुधार किया ताकि मैं बता सकूं कि मेरे कोड के साथ किसने शुरुआत की और उस वीडियो ट्यूटोरियल के साथ किसने शुरुआत की। उस कोड ने अपने जीवन पर लिया है, यह कई नौसिखिया प्रश्नों में दिखाई देता है। –