def init_window(self):
        self.master.title("MDitor")
        self.pack(fill=BOTH, expand=1)

        self.inputeditor = Text(self, width="1")
        self.inputeditor = Text(self, width="1", font=self.myfont)
        self.inputeditor.pack(fill=BOTH, expand=1, side=LEFT)

        # For output window
        self.outputbox = HTMLLabel(self,
                                   width="1",
                                   background="lightgray",
                                   html="START TYPING TO SEE OUTPUT...")
        self.outputbox.pack(fill=BOTH, expand=1, side=RIGHT)
        self.outputbox.fit_height()

        # change output as we type
        self.inputeditor.bind("<<Modified>>", self.onInputChange)
        # ctrl-s shortcut
        self.inputeditor.bind('<Control-s>', self.savefile)
        # ctrl-o shortcut
        self.inputeditor.bind('<Control-o>', self.openfile)
        # ctrl-h shortcut
        self.inputeditor.bind('<Control-h>', self.md2html)

        # File and Open
        self.mainmenu = Menu(self)
        self.filemenu = Menu(self.mainmenu)
        self.filemenu.add_command(label="Open", command=self.openfile)
        self.filemenu.add_command(label="Save as", command=self.savefile)
        self.filemenu.add_separator()
        self.filemenu.add_command(label="Exit", command=self.quit)
        self.mainmenu.add_cascade(label="File", menu=self.filemenu)
        self.mainmenu.add_cascade(label="Save HTML", command=self.md2html)
        self.master.config(menu=self.mainmenu)
示例#2
0
    def display_searching(self):

        if type(self.display_frame) is tkinter.Frame:
            self.display_frame.destroy()

        self.display_frame = tkinter.Frame(self.right)
        self.display_frame.pack(side='top',fill=BOTH,expand=1)

        self.canvas = tkinter.Canvas(self.display_frame)
        self.canvas.pack(side='left',fill=tkinter.BOTH,expand=1)

        self.scrollbar = ttk.Scrollbar(self.display_frame,orient=tkinter.VERTICAL,command=self.canvas.yview)
        self.scrollbar.pack(side='right',fill=tkinter.Y)

        self.canvas.configure(yscrollcommand=self.scrollbar.set)
        self.canvas.bind('<Configure>',lambda e: self.canvas.configure(scrollregion=self.canvas.bbox("all")))

        self.sec_frame = tkinter.Frame(self.canvas)
        self.canvas.create_window((0,0),window=self.sec_frame,anchor='nw',width=385)

        self.htmlsnippet = '''
            <div style="background-color:white;">
            <h5 style="color: orange">Searching for top results ...</h5>
            </div>
            '''     # HTML template for Searching Message.

        self.msg_display = HTMLLabel(self.sec_frame,html=self.htmlsnippet,height=6,background='white')
        self.msg_display.pack() 
示例#3
0
    def __createHTMLFrame(self, __w, __h, code):
        from tkhtmlview import HTMLLabel

        html = HTMLLabel(self.__HTMLviewer,
                         html=code,
                         width=__w,
                         height=__h - 140)
        html.pack(side=BOTTOM)
示例#4
0
    def __init__(self):

        # make the sticky sized window appear in the top right corner
        x = self.root.winfo_screenwidth() - self.width - 10
        self.root.geometry("%dx%d+%d+%d" %
                           (self.width, self.height, x, self.y))

        # add gui elements
        self.widgets["counter"] = Label(self.root, text="")
        self.widgets["counter"].pack()

        self.widgets["html_label"] = HTMLLabel(self.root, html="")
        self.widgets["html_label"].pack(fill="both", expand=True)
        self.widgets["html_label"].fit_height()

        self.widgets["bottomButtons"] = Frame(self.root)
        self.widgets["bottomButtons"].pack(side=BOTTOM)

        # make buttons to paginate through step list
        self.widgets["prev_button"] = Button(self.widgets["bottomButtons"],
                                             text="<",
                                             command=self.prev_step)
        self.widgets["prev_button"].grid(row=0, column=0)
        self.widgets["open_button"] = Button(self.widgets["bottomButtons"],
                                             text="o",
                                             command=self.open_file)
        self.widgets["open_button"].grid(row=0, column=1)
        self.widgets["next_button"] = Button(self.widgets["bottomButtons"],
                                             text=">",
                                             command=self.next_step)
        self.widgets["next_button"].grid(row=0, column=2)

        self.root["background"] = "#f1f58f"
        for widget in self.widgets:
            #print("widget: %s - widget type: %s" % (widget, type(widget)))
            self.widgets[widget].configure(bg="#f1f58f", bd=0, relief=FLAT)
        # because html_label only picks up color after the configure for some reason
        self.widgets["html_label"].set_html("")

        self.root.bind("<h>", lambda e: self.help_message())
        self.root.bind("<o>", lambda e: self.open_file())
        self.root.bind("<e>", lambda e: self.edit_file())
        self.root.bind("<Right>", lambda e: self.next_step())
        self.root.bind("<Left>", lambda e: self.prev_step())
        self.root.bind("<g>", lambda e: self.goto_step_number())
        self.root.bind("<Control-q>", lambda e: self.root.destroy())

        self.keybindings = dict()
        self.keybindings["h"] = "Show keybindings"
        self.keybindings["o"] = "Open local file"
        self.keybindings["e"] = "Edit file"
        self.keybindings["Right"] = "Go to next step"
        self.keybindings["Left"] = "Go to previous step"
        self.keybindings["g"] = "Go to step [number]"
        self.keybindings["Control-q"] = "Quit"
示例#5
0
def Results():
    Button(root, text="Exit", command=Main)
    root.title('Results')
    root.geometry("1200x800")
    upper_frame = Frame(
        root,
        bg='#4c8a27',
        bd=5,
    )
    upper_frame.place(relx=0.5,
                      rely=0.1,
                      relheight=0.2,
                      relwidth=0.8,
                      anchor="n")
    root_frame = Frame(root, bg='#4c8a27')
    lower_frame = Frame(
        root,
        bg='#4c8a27',
        bd=2,
    )
    lower_frame.place(relx=0.5,
                      rely=0.1,
                      relheight=0.15,
                      relwidth=1,
                      anchor="n")
    create_back_button(root_frame)
    root_frame.place(relx=0.5, rely=0.0, relheight=1, relwidth=1, anchor='n')
    Label(
        root_frame,
        text=
        "Click on the link 'Click to view all results' to open up a Google sheets with all results",
        bg='#4c8a27',
        font="AutobusBold 12 bold").place(x=275, y=60)
    Label(root_frame,
          text="Click to view all results",
          bg='#add8e6',
          font="AutobusBold 15 bold").place(x=300, y=20, width=599)
    HTMLLabel(
        lower_frame,
        state="normal",
        fg='black',
        font="AutobusBold 30 bold",
        bg='#add8e6',
        html=
        '<a href="https://docs.google.com/spreadsheets/d/1cn8pl7UIQzIvn65ByVGZq8QswEd-FMTGybK50ab84pk/edit?usp=sharing"> Click to view the '
        'Results </a>').place(x=300, y=50, width=599)
    create_back_button(root)
    root.mainloop()
    def init_window(self):
        self.master.title('Mardown Viewer')
        self.pack(fill=tk.BOTH, expand=1)

        self.mainmenu = tk.Menu(self)
        self.filemenu = tk.Menu(self.mainmenu)
        self.filemenu.add_command(label='Open', command=self.openfile)
        self.filemenu.add_separator()
        self.filemenu.add_command(label='Exit', command=self.quit)
        self.mainmenu.add_cascade(label='File', menu=self.filemenu)
        self.master.config(menu=self.mainmenu)

        self.outputbox = HTMLLabel(self, width='1', background='white',
                                   html='<h1>Welcome</h1>')
        self.outputbox.pack(fill=tk.BOTH, expand=1, side=tk.RIGHT)
        self.outputbox.fit_height()
示例#7
0
    def search_thread(self,command):

        self.display_searching()    # Display Searching Message.
        self.snippets = search_web(command) # Get Code Snippets
        self.display_frame.destroy()    # destroy existing display frame.

        # create Display Frame for displaying Search Query and Code Snippets.
        self.display_frame = tkinter.Frame(self.right)
        self.display_frame.pack(side='top',fill=BOTH,expand=1)

        self.canvas = tkinter.Canvas(self.display_frame)
        self.canvas.pack(side='left',fill=tkinter.BOTH,expand=1)

        self.scrollbar = ttk.Scrollbar(self.display_frame,orient=tkinter.VERTICAL,command=self.canvas.yview)
        self.scrollbar.pack(side='right',fill=tkinter.Y)

        self.canvas.configure(yscrollcommand=self.scrollbar.set)
        self.canvas.bind('<Configure>',lambda e: self.canvas.configure(scrollregion=self.canvas.bbox("all")))

        self.sec_frame = tkinter.Frame(self.canvas)
        self.canvas.create_window((0,0),window=self.sec_frame,anchor='nw',width=385)

        self.htmlsnippet = f'''
            <div style="background-color:white;">
            <h5 style="color: green">Recieved Command</h5>
            <p>{command}</p>
            </div>
        '''     # HTML template for recieved message.

        self.msg_display = HTMLLabel(self.sec_frame,html=self.htmlsnippet,height=6,background='white')
        self.msg_display.pack()

        self.separator = Label(self.sec_frame,text='--------------------------------------------------------------')
        self.separator.pack(side='top',fill='x',expand='no')

        # Display Code snippets.
        for i in range(len(self.snippets)):
            if len(self.snippets[i][2]) > 0:
                frami = Section(self.sec_frame,self.snippets[i][2],self.snippets[i][0],self.snippets[i][1])
                frami.pack(side='top',fill='x',expand=1)
                self.sections.append(frami)

        # Update Controller.
        self.controller.geometry("1361x600")
        self.controller.update()
        self.controller.geometry("1360x600")
        self.controller.update()
示例#8
0
def get_md_preview_frame(master, html_var: StringVar):
    md_prev_frame = HTMLLabel(master,
                              width='1',
                              height='1',
                              background=color['shell-dark'],
                              padx=16,
                              pady=16)

    def on_html_change(*_):
        # todo: find if there is any simpler way to change font color
        html_text = '<div style=\"color:' + color[
            'high'] + ';\">' + html_var.get() + '</div>'
        md_prev_frame.set_html(html_text)

    on_html_change()
    html_var.trace_add('write', on_html_change)
    return md_prev_frame
示例#9
0
 def init_window(self):
     self.pack(fill=BOTH, expand=1)
     self.inputeditor = Text(self, width="1", font=self.myfont, bg='black', insertbackground='white', fg='white',
                             wrap=WORD)
     self.inputeditor.pack(fill=BOTH, expand=1, side=LEFT)
     self.outputbox = HTMLLabel(self, width="1", background="white", html="<h1>Welcome</h1>")
     self.outputbox.pack(fill=BOTH, expand=1, side=RIGHT)
     self.outputbox.fit_height()
     self.inputeditor.bind("<<Modified>>", self.onInputChange)
     self.mainmenu = Menu(self.master.master)
     self.filemenu = Menu(self.mainmenu)
     self.filemenu.add_command(label="Open", command=self.openfile)
     self.filemenu.add_command(label="Save as", command=self.savefile)
     self.filemenu.add_separator()
     self.filemenu.add_command(label="Exit", command=self.quit)
     self.mainmenu.add_cascade(label="File", menu=self.filemenu)
     self.master.master.config(menu=self.mainmenu)
示例#10
0
    def google_search(self):
        try:
            from googlesearch import search
        except ImportError:
            print("An error when importing googlesearch has occurred.")
            return
        query = self.google_entry_str.get()
        self.result_screen.deiconify()
        self.result_screen.geometry("700x500")
        Label(self.result_screen,
              text="A list of URL's compiled by google.").pack()
        Label(self.result_screen, text="Keyword Searched: " + query).pack()

        for j in search(query, tld="co.in", num=5, stop=5):
            temp_label = HTMLLabel(self.result_screen,
                                   html='<a href="' + j + '">' + j + '</a>',
                                   fg="blue")
            temp_label.config(height=5)
            temp_label.pack()
示例#11
0
def main_func():
    global start, lbl3, country, textExample, countryCode_button, html_label
    lbl2.destroy()
    countries.destroy()
    lbl3 = Label(
        root,
        text="-------------"
        "--                                                 ---------------"
        "--\n    'The future is ours to shape.\n I feel we"
        "are in a race that we need to win.\n It’s a race between the growing"
        " power\nof the technology and the growing\n wisdom"
        " we need to manage it.'\n                                  "
        "   ~Max Tegmark"
        "                    \n---------------                               "
        "                  -----------------",
        bg="black",
        fg="white",
        font="Times 18",
        pady=10)
    lbl3.config(anchor=CENTER)
    lbl3.pack(pady=10)
    start.destroy()
    country = Label(root,
                    text='Enter the country code to setup the alerts',
                    bg="black",
                    fg="white",
                    font="Times 18",
                    pady=10)
    country.pack(side=TOP, pady=10)
    textExample = Text(root, height=1, width=12)
    textExample.pack(side=TOP, pady=5)
    countryCode_button = Button(root, text="Enter", command=retrieve_input)
    countryCode_button.pack(side=TOP, pady=10)
    html_label = HTMLLabel(root,
                           html='<a href="https://blockchain.info/ticker"'
                           'style="color: green; text-align: center"> '
                           ' Please visit:- https://blockchain.info/ticker,  '
                           ' to know all the listed countries </a>')
    # html_label.pack(fill="both", expand=True)
    html_label.pack()
    html_label.fit_height()
示例#12
0
    def __init__(self,parent,snippet,source,link):
        Frame.__init__(self,parent)
        self.html_code = f"""
                <h5> Source : <b style="color:red"> {source} </b> </h5>
                <a href="{link}">original code link</a>
        """
        self.source = HTMLLabel(self,html=self.html_code,height=5,background='white')
        self.source.pack(side='top')
        self.snippet = snippet

        self.code = Text(self, wrap='none', undo=1,background='black',fg='white',height=10)
        self.code.tag_configure("bigfont", font=("Helvetica", "24", "bold"))
        self.code.pack(side='top')
        self.code.insert(END,snippet)
        self.code.config(state=DISABLED)

        self.code_syntax_color=ColorLight.ColorLight(txtbox=self.code)
        self.code_syntax_color.trigger()

        self.copy = Button(self,text='COPY',command=self.copy_code)
        self.copy.pack(side='top')
示例#13
0
    def init_window(self):
        self.master.title("Markdown 编辑器")
        self.pack(fill=BOTH, expand=1)

        self.inputeditor = Text(self, width="1", font=self.myfont)
        self.inputeditor.pack(fill=BOTH, expand=1, side=LEFT)

        self.outputbox = HTMLLabel(self, width="1", background="white", html="<h1>Markdown 编辑器</h1>")
        self.outputbox.pack(fill=BOTH, expand=1, side=RIGHT)
        self.outputbox.fit_height()

        self.inputeditor.bind("<<Modified>>", self.onInputChange)

        self.mainmenu = Menu(self)
        self.filemenu = Menu(self.mainmenu)
        self.filemenu.add_command(label="打开", command=self.openfile)
        self.filemenu.add_command(label="另存为", command=self.savefile)
        self.filemenu.add_separator()
        self.filemenu.add_command(label="退出", command=self.quit)
        self.mainmenu.add_cascade(label="文件", menu=self.filemenu)
        self.master.config(menu=self.mainmenu)
示例#14
0
    def add_msg_frame(self,typeofmsg):

        # Destroy the existing Code Display Frame.
        if type(self.display_frame) is tkinter.Frame:
            self.display_frame.destroy()

        #++++++++++++++++++++++++ [New Code Display Section] ++++++++++++++++++++++++++++++++++++++++++++++
        self.display_frame = tkinter.Frame(self.right)
        self.display_frame.pack(side='top',fill=BOTH,expand=1)

        self.canvas = tkinter.Canvas(self.display_frame)
        self.canvas.pack(side='left',fill=tkinter.BOTH,expand=1)

        self.scrollbar = ttk.Scrollbar(self.display_frame,orient=tkinter.VERTICAL,command=self.canvas.yview)
        self.scrollbar.pack(side='right',fill=tkinter.Y)

        self.canvas.configure(yscrollcommand=self.scrollbar.set)
        self.canvas.bind('<Configure>',lambda e: self.canvas.configure(scrollregion=self.canvas.bbox("all")))

        self.sec_frame = tkinter.Frame(self.canvas)
        self.canvas.create_window((0,0),window=self.sec_frame,anchor='nw',width=385)

        # Set MIC Status.
        if typeofmsg == 1:
            self.htmlsnippet = '''
                <div style="background-color:white;">
                <h5 style="color: blue">I'm Listening...</h5>
                <p>speak after the sound</p>
                </div>
            '''         # HTML div to display MIC status.
        else:
            self.htmlsnippet = '''
                <div style="background-color:white;">
                <h5 style="color: red">Error</h5>
                <p>Didn't understand, Please try again</p>
                </div>
            '''      # HTML div to display Error Message.

        self.msg_display = HTMLLabel(self.sec_frame,html=self.htmlsnippet,height=6,background='white')  # Display Status of Tool and MIC
        self.msg_display.pack()
            cv2.imshow("preview", frame)
#            if Answer==tkvar:
#                cv2.putText(frame, "Worked well", (x, y), cv2.FONT_HERSHEY_SIMPLEX,
#                            0.5, color, 2)
#            else:
#                cv2.putText(frame, "Try again", (x, y), cv2.FONT_HERSHEY_SIMPLEX,
#                            0.5, color, 2)
    camera.release()

    cv2.destroyAllWindows()
    #print(Answer)


#w = Label(root, text="You can contribute at").grid(row = 4, column = 0)
#t=HTMLLabel(root, html='<a href="https://childrenwithhearingloss.org/"> NGO </a>',font=("Courier", 1)).grid(row=5,column=0)

w = Label(root, text="Learn Sign Language").grid(row=4, column=0)
t = HTMLLabel(
    root,
    html='<a href="https://www.youtube.com/watch?v=Raa0vBXA8OQ"> Tutorial </a>',
    font=("Courier", 1)).grid(row=5, column=0)

B = Button(root, text="Practice", command=press,
           font=("Times New Roman", 30)).grid(row=3, column=0)

w = Label(root, text="ASL Practice Arena",
          font=("Times New Roman", 20)).grid(row=1, column=0)

#tkvar.trace('w', change_dropdown)

root.mainloop()
示例#16
0
    def search(self, keyword, endpoint, param1, param2):
        global entry
        global olist
        global res
        if endpoint == None:
            c.execute(f'SELECT * FROM {param1} LIMIT {param2}')
            data = c.fetchall()
            print(data)
            f = Frame(self.master)
            f.place(x=50, y=250, width=300)
            scroll_bar = Scrollbar(f)

            scroll_bar.pack(side=RIGHT, fill=Y)
            olist = Listbox(f, yscrollcommand=scroll_bar.set)
            olist.pack(fill=BOTH)
            scroll_bar.config(command=olist.yview)
            for i in range(len(data)):
                olist.insert(i, data[i][2])
        else:

            searchtext = entry.get()
            print(searchtext)

            # Step 1 - Authorization
            url = "https://accounts.spotify.com/api/token"
            headers = {}
            data = {}

            # Encode as Base64

            clientId = "<Enter your client Id>"
            clientSecret = "<Enter your Client Secret>"

            message = f"{clientId}:{clientSecret}"
            messageBytes = message.encode('ascii')
            base64Bytes = base64.b64encode(messageBytes)
            base64Message = base64Bytes.decode('ascii')

            headers['Authorization'] = f"Basic {base64Message}"
            data['grant_type'] = "client_credentials"

            r = requests.post(url, headers=headers, data=data)

            token = r.json()['access_token']
            #print(token)

            token = r.json()['access_token']

            # Step 2 - Use Access Token to call playlist endpoint

            print(keyword)
            print(searchtext)

            from googlesearch import search
            query = "spotify" + keyword + searchtext
            for i in search(query, num=1, stop=1):
                print(i)
            spotifyId = i.split("/")[-1]
            print(spotifyId)

            #playlistId = "7nYJDIm5nHyNTS2KugaD4w"
            if endpoint == "https://api.spotify.com/v1/artists":
                spotifyUrl = f"{endpoint}/{spotifyId}/top-tracks?market=ES"

            else:
                spotifyUrl = f"{endpoint}/{spotifyId}"

            print(spotifyUrl)

            headers = {"Authorization": "Bearer " + token}

            res = requests.get(url=spotifyUrl, headers=headers)
            f = Frame(self.master)
            f.place(x=50, y=250, width=300)
            scroll_bar = Scrollbar(f)

            scroll_bar.pack(side=RIGHT, fill=Y)
            olist = Listbox(f, yscrollcommand=scroll_bar.set)
            olist.pack(fill=BOTH)
            scroll_bar.config(command=olist.yview)

            print(res.json())

            if endpoint == "https://api.spotify.com/v1/artists":

                for i in res.json()["tracks"]:
                    olist.insert(END, i[param1][param2])

                    c.execute(
                        'INSERT INTO artisearch(id,Artist_Searched,Songs) VALUES(?,?,?)',
                        (self.counter, searchtext, i[param1][param2]))
                    self.counter += 1
                    con.commit()

            elif endpoint == "https://api.spotify.com/v1/tracks":

                for i in (res.json()["artists"]):
                    olist.insert(END, i[param1][param2])

                    webbrowser.open(i[param1][param2])
                    c.execute(
                        'INSERT INTO songisearch(id,Song_Searched,Url) VALUES(?,?,?)',
                        (self.counter, searchtext, i[param1][param2]))
                    self.counter += 1
                    con.commit()
            else:
                for i in range(len(res.json()["tracks"]['items'])):

                    olist.insert(
                        END,
                        res.json()["tracks"]['items'][i][param1][param2])

                    c.execute(
                        'INSERT INTO playlisearch(id,Playlist_Searched,Songs) VALUES(?,?,?)',
                        (self.counter, searchtext,
                         res.json()["tracks"]['items'][i][param1][param2]))
                    self.counter += 1
                    con.commit()

            my_label = HTMLLabel(self.master,
                                 html=f"""
            <a style = "text-align : center;" href ="https://open.spotify.com/embed/{keyword}/{spotifyId}" width="50%" height="10" frameborder="0" allowtransparency="true" allow="encrypted-media">LISTEN NOW</a>
            """)
            # Adjust label
            my_label.place(x=400, y=250, width=100, height=27)
示例#17
0
    return html


htmlChatConsoleWindow = tk.Frame(notebookTab3, width=335, height=150)
htmlChatConsoleWindow.pack(fill="both", side="left", expand=True)
htmlWindow = tk.Frame(htmlChatConsoleWindow, width=335, height=150)
htmlWindow.pack(fill=BOTH, expand=1)
htmlWindow.myfont = font.Font(family="Helvetica", size=14)
htmlWindow.pack(fill=BOTH, expand=1)
htmlWindow.inputeditor = Text(htmlWindow,
                              width="1",
                              height="0.25",
                              font=htmlWindow.myfont)
htmlWindow.inputeditor.pack(fill=X, expand=1, side=BOTTOM)
htmlWindow.outputbox = HTMLLabel(htmlWindow,
                                 width="1",
                                 background="gray",
                                 html="<h1>Welcome</h1>")
htmlWindow.outputbox.pack(fill="both", expand=1, side=TOP)
htmlWindow.outputbox.fit_height()
htmlWindow.inputeditor.bind("<Return>", onInputChange)

#  ______________________________________________________________
# | "Buttons" | Contains all the buttons that the user has added |
#  ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
#Scrollbar
useCommandsScrollbar = ttk.Scrollbar(useCommandsFrame, orient="vertical")
useCommandsScrollbar.grid(column=1, row=0)

#Command Buttons
savedCommands = get_commands(SAVE_FILE_NAME)
for commandTuple in savedCommands:
示例#18
0
import tkinter as tk
from tkhtmlview import HTMLLabel

win = tk.Tk()
win.title("Link in Tkinter")

instagram = HTMLLabel(win, html='<a href ="www.instagram.com"> Instagram </a>')
google = HTMLLabel(win, html='<a href = "www.google.co.in"> Google </a>')
whatsapp = HTMLLabel(win, html='<a href ="web.whatsapp.com"> Whatsapp </a>')
News = HTMLLabel(
    win,
    html=
    '<a href ="news.google.com/topstories?hl=en-IN&gl=IN&ceid=IN:en"> News </a>'
)
instagram.grid(row=0, column=0)
google.grid(row=0, column=1)
whatsapp.grid(row=0, column=2)
News.grid(row=1, column=0)

win.mainloop()
示例#19
0
import tkinter as tk
from tkhtmlview import HTMLLabel

root = tk.Tk()
html_label = HTMLLabel(
    root, html='<a href="http://www.google.com"> Google Hyperlink </a>')
html_label.pack()
root.mainloop()
示例#20
0
def main():
    global p1
    global p2
    global p1engine, p2engine
    global boardCanvas
    global canvasSize
    global app
    global root
    global board
    global clickDragging
    global flipped
    global gameStateVar, gameStateLabel
    global engine1
    global engine2
    global keeprunning
    global gameinprogerss
    global my_html_label
    global button_startpos, button_back, button_forward, button_end
    global checkbutton_highlight
    global movestack, movestackend
    global checkbutton_state

    gameinprogress = False

    flipped = False
    clickDragging = False

    root = tk.Tk()

    # position/dimensions for main tk frame
    x = 100
    y = 100
    w = 887
    h = 505
    oldappheight = h
    oldappwidth = w
    geostring = "%dx%d+%d+%d" % (w, h, x, y)

    root.geometry(geostring)
    app = TkFrame(root)
    app.bind("<Configure>", appresize)

    boardCanvas = Canvas(app, width=480, height=480)

    boardCanvas.bind("<Button-1>", canvasClick)
    boardCanvas.bind("<ButtonRelease-1>", canvasRelease)
    boardCanvas.bind("<B1-Motion>", canvasMotion)

    boardCanvas.pack(expand=YES)
    boardCanvas.place(x=0, y=0)

    gameStateVar = StringVar()

    gameStateLabel = Label(root,
                           font=('calibri', 15),
                           justify=LEFT,
                           anchor="w",
                           textvariable=gameStateVar)
    gameStateLabel.pack()
    gameStateLabel.place(x=0, y=480)

    my_html_label = HTMLLabel(root, html="opening text appears here")
    my_html_label.pack(pady=20, padx=20, fill="both", expand=True)

    button_startpos = Button(root, width=100, height=48, text="<<")
    button_startpos.pack()
    button_back = Button(root, text="<")
    button_back.pack()
    button_forward = Button(root, text=">")
    button_forward.pack()
    button_end = Button(root, text=">>")
    button_end.pack()
    checkbutton_state = IntVar(value=1)
    checkbutton_highlight = Checkbutton(root,
                                        text="Highlight Book Moves",
                                        variable=checkbutton_state)

    button_back.bind("<ButtonRelease-1>", movelistBack)
    button_startpos.bind("<ButtonRelease-1>", movelistStartpos)
    button_forward.bind("<ButtonRelease-1>", movelistForward)
    button_end.bind("<ButtonRelease-1>", movelistEnd)
    checkbutton_highlight.bind("<ButtonRelease-1>", updatehighlight)
    f = open("chessopeningtheory/index.html", "r", encoding="utf-8")
    html = f.read()
    f.close()
    newhtml = ""
    allowwrite = 0
    for line in html.splitlines():
        ignoreline = False
        if "<meta property=\"og:title\"" in line:
            allowwrite = 1
        if "<img" in line: ignoreline = True
        if "<td style=\"padding:0px 0.5em; border-right:1px solid #aaa;\">" in line:
            ignoreline = True
        if "<td style=\"border-bottom:1px solid #aaa;\">" in line:
            ignoreline = True
        if "<td style=\"padding:0px 0.5em; border-left:1px solid #aaa;\">" in line:
            ignoreline = True
        if "<td style=\"border-top:1px solid #aaa;\">" in line:
            ignoreline = True
        if "<td style=\"background-color:white\">" in line and line[
                -1] >= 'a' and line[-1] <= 'h':
            ignoreline = True
        if "<td style=\"background-color:white\">" in line and line[
                -1] >= '1' and line[-1] <= '8':
            ignoreline = True
        if "<td>" in line and "</td>" in line and line[4] >= 'a' and line[
                4] <= 'h':
            ignoreline = True
        if "<td>" in line and "</td>" in line and line[4] >= '1' and line[
                4] <= '8':
            ignoreline = True
        if "id=\"References\">References<" in line: allowwrite = 0
        if allowwrite and not ignoreline: newhtml += line + "\n"
    my_html_label.set_html(newhtml)
    p1 = "Human"
    p2 = "Human"
    """
    if (p1 == "AI"):
        engine1 = chess.engine.SimpleEngine.popen_uci("c:\\engines\\stockfish11.exe")

    if (p2 == "AI"):
        engine2 = chess.engine.SimpleEngine.popen_uci("c:\\c\\raven-weak\\raven-weak.exe")
    """
    initGame(p1, p2)
    #root.update()

    drawBoard()
    drawPieces()
    highlightPieces()
    #root.after(1, mainloop())

    root.protocol("WM_DELETE_WINDOW", on_closing)
    root.mainloop()
import tkinter as tk
from tkhtmlview import HTMLLabel

root = tk.Tk()
root.title("Test Html on Tkinter")
root.configure(bg='black')

data = """<!-- Dynamic Coding output code  -->
<p style="border: 2px solid rgb(51, 103, 214); font-size: 15px; padding: 0.2em 0.6em;"><font face="arial">
<kbd style="border-radius: 0px; border: 1px solid rgb(51, 103, 214); padding: 3px;color:#3367d6;"><b>&nbsp;  Output &nbsp;</b></kbd>
<br />
<code style="color:#ff0000">
deque(['A', 'B', 'C', 'D'])


</code>
</font></p>
<br />


"""
html_label = HTMLLabel(root, html=data)
html_label.pack(fill="both", expand=True)
html_label.fit_height()
root.mainloop()
示例#22
0
import tkinter as tk
from tkhtmlview import HTMLLabel

root = tk.Tk()
html_label = HTMLLabel(
    root, html='<h1 style="color: red; text-align: center"> Hello World </H1>')
html_label.pack(fill="both", expand=True)
html_label.fit_height()
root.mainloop()
    markdown = Markdown()
    markdownText = markdown_editor.get("1.0", END)
    html = markdown.convert(markdownText)
    result.set_html(html)


# Creating tkinter window
window = Tk()
window.title('Markdown viewer')
window.geometry('1200x1000')
window.configure(bg='white')

# Styling font and button
myfont = font.Font(family="Helvetica", size=14)
style = Style()
style.configure('TButton', font=('calibri', 20, 'bold'), foreground='Blue')

# Placing widgets into Tkinter window
submit_btn = Button(text="View Markdown", command=onKeyUp, style='TButton')
submit_btn.pack(ipadx=30, ipady=6)

markdown_editor = Text(width="1", insertborderwidth=2, selectborderwidth=2)
markdown_editor.insert(END, '# Add Markdown here')
markdown_editor.pack(fill=BOTH, expand=1, side=LEFT, padx=10, pady=10)
markdown_editor.configure(font=myfont)

result = HTMLLabel(width="1", html="<h1>Markdown Viewer</h1>")
result.pack(fill=BOTH, expand=1, side=RIGHT, padx=10, pady=10)

window.mainloop()
示例#24
0
# Set Geomerty of window
root.geometry("400x500")
root.title("Image viewer and downloader")

# Set styles
style = ttk.Style()
style.theme_use('alt')
style.map('my.TButton', background=[('active', 'white')])
style.configure('my.TButton', font=('Helvetica', 16, 'bold'))
style.configure('my.TButton', background='white')
style.configure('my.TButton', foreground='orange')
style.configure('my.TFrame', background='white')

# Add labels and buttons
my_label = HTMLLabel(root)

search_box = Entry(root, font=("Helvetica 15"), bd=2, width=60)
search_box.pack(side=TOP, pady=5, padx=15, ipadx=5)

search_btn = ttk.Button(text="Scrape Image!",
                        command=showImage,
                        style='my.TButton')
search_btn.pack(side=TOP)

save_btn = ttk.Button(text="Download Image!",
                      command=saveImage,
                      style='my.TButton')
save_btn.pack(side=TOP)

my_label.pack(pady=20, padx=20)
示例#25
0
root.title('uing HTML')
root.iconbitmap('ergo64.ico')
root.geometry('500x600')

# my_label = HTMLLabel (root, html="<a href='https://codemy.com'> LEARN TO CODE </a>")
my_label = HTMLLabel(root,
                     html="\
    <h1>\
        <a href='https://codemy.com'> LEARN TO CODE </a>\
    </h1>\
        <ol>\
        <li>One</li>\
        <li>Two</li>\
        <li>Three</li>\
        <li>Four</li>\
        </ol>\
        <ul>\
        <li><h4>One</h4></li>\
        <li><h5>Two</h5></li>\
        <li>Three</li>\
        <li>Four</li>\
        </ul>\
        <img src='https://cdn.codemy.com/wp-content/uploads/2015/01/sp21212.png'>\
        <img src = 'C:/Users/eric/Pictures/mando2.png'>\
    <pre><h1>\
        <a href='https://codemy.com'> LEARN TO CODE </a>\
    </h1></pre>\
        ")
my_label.pack(pady=20, padx=20, fill="both", expand=True)

root.mainloop()
示例#26
0
from tkinter import *
from tkhtmlview import HTMLLabel

root = Tk()
root.title("Python Tkinter How To Use HTML In Your Tkinter App")
root.geometry("500x600")

my_label = HTMLLabel(root,
                     html="\
    <h1>\
    <a href='https://www.python.org/'>Download Python</a>\
    </h1>\
    <ul>\
    <li>One </li>\
    <li>Two </li>\
    <li>three </li>\
    </ul>\
    <img src='https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTr9vl91PpaNrX7_EiOaWpTyftYzOFEiQixBA&usqp=CAU'> "
                     )

my_label.pack(pady=20, padx=20, fill="both", expand=True)

root.mainloop()
示例#27
0
Button(quickmenu, text="斜体", command=unc, width=6, height=3).place(x=300, y=50)
Button(quickmenu, text="引用", command=userfrom, width=6, height=3).place(x=360,
                                                                        y=50)
Button(quickmenu, text="图片", command=pic, width=6, height=3).place(x=420, y=50)
Button(quickmenu, text="超链接", command=superlink, width=6,
       height=3).place(x=480, y=50)

tools.place(x=0, y=0)


def onInputChange(event):
    inputeditor.edit_modified(0)
    md2html = Markdown()
    outputbox.set_html(md2html.convert(inputeditor.get("1.0", END)))


inputeditor = Text(showbar, height=70, width=60)
#inputeditor.pack(fill=BOTH, expand=1, side=LEFT)
inputeditor.pack(side=LEFT, fill=BOTH)
outputbox = HTMLLabel(showbar,
                      background="white",
                      html="<h1>这里什么也没有写</h1>",
                      height=600,
                      width=55)
outputbox.pack(side=RIGHT, fill=BOTH)
inputeditor.bind("<<Modified>>", onInputChange)
#outputbox.pack(fill=BOTH, expand=1, side=RIGHT)
outputbox.fit_height()
#Button(showbar).place(x=0,y=0)\

root.mainloop()
from tkinter import *
from tkhtmlview import HTMLLabel

root = Tk()
root.title('Codemy.com - Using HTML')
root.iconbitmap('c:/gui/codemy.ico')
root.geometry("500x600")

my_label = HTMLLabel(root,
                     html="\
	<code><h1>\
	<a href='https://codemy.com'>Learn To Code!</a>\
	</h1></code>\
	<ul>\
	<li>One</li>\
	<li>Two</li>\
	<li>Three</li>\
	</ul>\
	<img src='c:/gui/images/aspen.png'>")

my_label.pack(pady=20, padx=20, fill="both", expand=True)

root.mainloop()
示例#29
0
Éditeur : Laurent REYNAUD
Date : 11-02-2021
"""

# module qui requiert les packages
# requests et Pillow pour les liens HTML
from tkhtmlview import HTMLLabel
import tkinter

root = tkinter.Tk()
root.iconbitmap('images/Logo.ico')
root.title('Titre !')
root.geometry('600x650')
"""Configuration d'une étiquette en HTML qui comprend : 
-> le lien @ du cours à partir d'une certaine séquence ; 
-> téléchargement de l'image du site codemy.com 
(clique droit puis copier l'adresse de l'image) ; 
-> une liste ordonnée 
"""
my_label = HTMLLabel(
    root,
    html=
    "<h1><pre><a href=https://youtu.be/d6UitRCstiQ?t=377>Coder avec HTML</a></pre></h1>"  # lien @
    "<img src=https://cdn.codemy.com/wp-content/uploads/2015/01/sp21212.png>"  # image téléchargée
    "<ol><li>Un</li><li>Deux</li><li>Trois</li><li>Houlala !!!</li></ol>"  # liste ordonnée
)
my_label.pack(pady=20, padx=20, fill="both", expand=True)

root.mainloop()