Begin renderer
This commit is contained in:
parent
03e7a0abfc
commit
9c83fa873a
|
@ -0,0 +1,35 @@
|
|||
import tkinter as tk
|
||||
|
||||
def myTest(test):
|
||||
print("coucou")
|
||||
print(test)
|
||||
|
||||
class Renderer():
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
self.content = tk.Text(self.parent)
|
||||
self.currX = 0
|
||||
self.currY = 1
|
||||
self.addNormalText("test")
|
||||
self.addLink("mylink")
|
||||
self.addNormalText("test2")
|
||||
self.addLink("mylink2")
|
||||
self.content['state'] = 'disabled'
|
||||
self.content.pack()
|
||||
|
||||
def addNormalText(self, text):
|
||||
self.content.insert(str(self.currY)+'.'+str(self.currX), text+"\n")
|
||||
self.currY+=1
|
||||
|
||||
def addLink(self, text):
|
||||
index1 = str(self.currY)+'.'+str(self.currX)
|
||||
self.content.tag_bind("link-"+index1, "<Button-1>", lambda event, url=text:
|
||||
print(url))
|
||||
self.content.insert(index1, text+"\n")
|
||||
self.content.tag_add("link-"+index1, index1, str(self.currY)+'.'+str(self.currX+len(text)))
|
||||
self.currY+=1
|
||||
|
||||
app = tk.Tk()
|
||||
app.title("Test")
|
||||
render = Renderer(app)
|
||||
app.mainloop()
|
Reference in New Issue