From 1abc943669f64e1e248ffa6e35dc8bc14cc819cb Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Thu, 3 Dec 2020 10:02:32 +0100 Subject: [PATCH] A new awesome Gemini client (I hope) --- main.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..522f1cd --- /dev/null +++ b/main.py @@ -0,0 +1,44 @@ +import tkinter as tk + +# See https://tildegit.org/solderpunk/gemini-demo-1/src/branch/master/gemini-demo.py + +class Application(): + def __init__(self): + self.root = tk.Tk() + self.nav_bar = NavBar(self) + self.content = Content(self) + self.root.mainloop() + self.current_URL = "about:home" + + def updateContent(self): + text = self.nav_bar.getURL() + self.content.setContent(text) + self.current_URL = text + +class NavBar(): + def __init__(self, parent): + self.parent = parent + self.URL_var = tk.StringVar() + self.root = tk.Frame(self.parent.root) + self.root.grid(column=0, row=0) + self.URL_bar = tk.Entry(self.root, textvariable=self.URL_var) + self.URL_var.set("about:home") + self.URL_bar.grid(column=0, row=0) + self.go_button = tk.Button(self.root, text='Go !', command=self.parent.updateContent) + self.go_button.grid(column=1, row=0) + + def getURL(self): + return self.URL_var.get() + +class Content(): + def __init__(self, parent): + self.parent = parent + self.root = tk.Frame(self.parent.root) + self.root.grid(column=0, row=1) + self.line = tk.Label(self.root, text="My home page") + self.line.grid(column=0, row=0) + + def setContent(self, new_content): + self.line["text"] = new_content + +app = Application()