示例#1
0
    def insert_html_map(self):
        # https://stackoverflow.com/questions/46571448/tkinter-and-a-html-file
        frame = HtmlFrame(self.master, horizontal_scrollbar="auto")

        frame.set_content("<html>aadaaf </html>")
        #frame.set_content(urllib.request.urlopen("http://thonny.cs.ut.ee").read().decode())
        print("enter insert_html_map: ")
示例#2
0
class MainWindow(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.setupUI()

    def setupUI(self):
        self.master.title("Markwhat")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        self.grid_columnconfigure(0, weight=1)
        self.grid_columnconfigure(1, weight=1)
        self.rowconfigure(1, weight=1)

        self.markwhat_label = Label(self, text="Markwhat")
        self.markwhat_label.grid(sticky=W, row=0, column=0)

        self.markwhat_textarea = WhatText(self, background='white')
        self.markwhat_textarea.grid(row=1, column=0, sticky=NSEW)
        self.markwhat_textarea.beenModified = self.on_markwhat_modfified

        self.markup_label = Label(self, text="Markup")
        self.markup_label.grid(sticky=W, row=0, column=1)

        self.markup_preview = HtmlFrame(self)
        self.markup_preview.grid(row=1, column=1, sticky=NSEW)

        self.preview_button_text = StringVar()
        self.preview_button = Button(
            self,
            textvariable=self.preview_button_text,
            command=self.on_preview_click,
        )
        self.preview_button_text.set('HTML')
        self.preview_button.grid(row=2, column=1, sticky=W)

    def on_markwhat_modfified(self, event):
        text = self.markwhat_textarea.get('1.0', END)
        markup_text = parse_markdown(text)

        if isinstance(self.markup_preview, HtmlFrame):
            self.markup_preview.set_content(markup_text)
        else:
            self.markup_preview.delete('1.0', END)
            self.markup_preview.insert('1.0', markup_text)

    def on_preview_click(self):
        if isinstance(self.markup_preview, HtmlFrame):
            self.markup_preview = WhatText(self, background="white")
            self.preview_button_text.set('HTML')
        else:
            self.markup_preview = HtmlFrame(self)
            self.preview_button_text.set('HTML Source')

        self.markup_preview.grid(row=1, column=1, sticky=NSEW)
        self.on_markwhat_modfified(None)
示例#3
0
    def on_preview_click(self):
        if isinstance(self.markup_preview, HtmlFrame):
            self.markup_preview = WhatText(self, background="white")
            self.preview_button_text.set('HTML')
        else:
            self.markup_preview = HtmlFrame(self)
            self.preview_button_text.set('HTML Source')

        self.markup_preview.grid(row=1, column=1, sticky=NSEW)
        self.on_markwhat_modfified(None)
示例#4
0
    def __init__(self, parent: MainWindow):
        super().__init__(parent)
        self.__parent = parent
        self.__email_renderer = HtmlFrame(self)
        self.__text_display = Text(self)
        self.back_button = ttk.Button(self)
        self.respond_button = ttk.Button(self)
        self.redirect_button = ttk.Button(self)
        self.header = ttk.Label(self)

        self.__setup__email_rendering_screen()
    def __init__(self):
        self.root = tk.Tk()
        self.root.geometry("1000x700")
        self.root.title('RSS Enterprise')
        # self.root.iconbitmap("/home/stef/Python/rss_enterprise/icon.ico")

        self.settings_folder_path = os.path.join(Path.home(),
                                                 '.rss_enterprise')

        self.assert_settings()

        with open(self.get_cache_path(), mode='a') as self.fp_cache:
            top_frame = Frame(self.root)
            top_frame.pack(fill=BOTH, expand=True)

            bottom_frame = Frame(self.root)
            bottom_frame.pack(fill=BOTH, expand=True)

            self.tree = ttk.Treeview(top_frame,
                                     selectmode='browse',
                                     columns=(
                                         'title',
                                         'feed',
                                         'published',
                                     ))
            self.refresh_list()

            scrollbar_tree = ttk.Scrollbar(top_frame,
                                           orient="vertical",
                                           command=self.tree.yview)
            self.tree.configure(yscrollcommand=scrollbar_tree.set)
            self.tree.bind("<<TreeviewSelect>>", self.on_tree_select)
            self.tree.bind('<Return>', self.open_current_weblink)
            self.tree.heading('#0', text='title', anchor=tk.CENTER)
            self.tree.heading('#1', text='feed', anchor=tk.CENTER)
            self.tree.heading('#2', text='published', anchor=tk.CENTER)

            self.tree.column('#0', stretch=tk.YES, minwidth=50, width=630)
            self.tree.column('#1', stretch=tk.YES, minwidth=50, width=150)
            self.tree.column('#2', stretch=tk.YES, minwidth=50, width=200)

            scrollbar_tree.pack(side='right', fill='y')
            self.tree.pack(fill=BOTH, expand=True)

            self.text = HtmlFrame(self.root,
                                  fontscale=1.2,
                                  horizontal_scrollbar="auto")
            self.text.pack(fill=BOTH, expand=True)

            self.root.mainloop()
示例#6
0
    def __init__(self):
        self.root = Tk()
        self.root.geometry("500x300")
        self.root.title("MORtty Terminal - Info")
        self.root.configure(background="white")
        self.WebPage = HtmlFrame(self.root)
        self.WebPage.set_content('''<p align=center>hgihk</p>''')
        self.WebPage.place(relx=0.0, rely=0.0, relheight=0.9, relwidth=1.0)

        self.ButtonFrame = Frame(self.root)
        self.ButtonFrame.place(relx=0.0, rely=0.9, relheight=0.1, relwidth=1.0)

        self.Closebutton = Button(self.ButtonFrame)
        self.Closebutton.configure(text='Close', command=self.root.destroy)
        self.Closebutton.place(relx=0.5, rely=0.5, anchor='center')
示例#7
0
    def setupUI(self):
        self.master.title("Markwhat")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        self.grid_columnconfigure(0, weight=1)
        self.grid_columnconfigure(1, weight=1)
        self.rowconfigure(1, weight=1)

        self.markwhat_label = Label(self, text="Markwhat")
        self.markwhat_label.grid(sticky=W, row=0, column=0)

        self.markwhat_textarea = WhatText(self, background='white')
        self.markwhat_textarea.grid(row=1, column=0, sticky=NSEW)
        self.markwhat_textarea.beenModified = self.on_markwhat_modfified

        self.markup_label = Label(self, text="Markup")
        self.markup_label.grid(sticky=W, row=0, column=1)

        self.markup_preview = HtmlFrame(self)
        self.markup_preview.grid(row=1, column=1, sticky=NSEW)

        self.preview_button_text = StringVar()
        self.preview_button = Button(
            self,
            textvariable=self.preview_button_text,
            command=self.on_preview_click,
        )
        self.preview_button_text.set('HTML')
        self.preview_button.grid(row=2, column=1, sticky=W)
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()

        # Global vars
        self.messages = []

        # Create Widgets
        self.btn_connect = Button(self, text="Connect", command=self.connect)
        self.chat_messages = HtmlFrame(self, horizontal_scrollbar="auto")
        self.message_entry_value = StringVar()
        self.message_entry = Entry(self, textvariable=self.message_entry_value)
        self.btn_send_msg = Button(self, text="Send", command=self.send_msg)
        self.label_status = Label(self, text="Disconnected")

        # Pack widgets
        self.pack_widgets()
示例#9
0
 def make_map(self):
     mapa = Mapa()
     try:
         if not self.flag_map:
             self.flag_map = True
             root = tk.Tk()
             frame = HtmlFrame(root, horizontal_scrollbar="auto")
             mapita = mapa.armar_mapa(
                 lista_de_nombre_de_ubicaciones).render_mapa()
             mapa.guardar_mapa()
     except UbicacionNotFound as e:
         messagebox.showinfo("Ojo al piojo", str(e))
示例#10
0
 def online_image_classify(self,tab1,url):
         try:
                 vr_api = IAMAuthenticator("paste here") #paste visual recognition your API Key
                 vr1=vr(version="2018-03-19",authenticator=vr_api)
                 vr1.set_service_url("paste here") #paste your visual recognition your service URL
                 if url.get().split(".")[-1] == "gif" or url.get().split(".")[-1] == "jpg" or url.get().split(".")[-1] == "png" or url.get().split(".")[-1] == "tif" or url.get().split(".")[-1] == "jpeg":
                         ibm_result=vr1.classify(url=url.get()).get_result()
                         result = ttk.Label(tab1,text= "Result")
                         clear_btm=Button(tab1,text="Clear result",bg="black",fg="white")
                         result["font"] = font.Font(family='Comic Sans MS', size=15, weight='bold',underline = True )
                         result1='''<html><head></head><body><table style="width:100%" border="1"><tr><th><h2 style="color:red;font-family:Comic Sans MS">Classification</h2></th><th><h2 style="color:red;font-family:Comic Sans MS">Confident Score<h2></th></tr>'''
                         for i in range(len(ibm_result["images"][0]["classifiers"][0]["classes"])):
                                 result1=result1+f'<tr><td><center><h3 style="color:blue;font-family:Comic Sans MS">{ibm_result["images"][0]["classifiers"][0]["classes"][i]["class"]}</h3> </center></td><td><center><h3 style="color:blue;font-family:Comic Sans MS"> {str(round(ibm_result["images"][0]["classifiers"][0]["classes"][i]["score"]*100))}%</h3> </center></td></tr>'
                         result1=result1+f'</table></body></html>'
                         frame = HtmlFrame(tab1,horizontal_scrollbar="auto",vertical_scrollbar="auto")
                         frame.set_content(result1)
                         clear_btm["command"] = lambda one=result, two=clear_btm, three=frame: self.clear(one,two,three)
                         clear_btm["font"] = font.Font(family='Comic Sans MS', size=10,weight='bold')
                         clear_btm.pack()
                         result.pack()
                         frame.pack()
                 else:
                         raise NameError()
         except:
                 messagebox.showwarning(title="URL Error", message=f'''Please enter the proper image URL to classify.\nThe given URl is not a image URL.\nThe given URL is {url.get()}\n The proper image url will end with .gif/.jpg/.png/.tif.''')
示例#11
0
def displayhtml():

    global fram1
    frame = HtmlFrame(fram1, horizontal_scrollbar="true")
    frame.grid(sticky=NSEW)
    file_read = open("dialog.html", "r")
    frame.set_content(file_read.read())
示例#12
0
 def speech_to_text(self,master):
         speech_to_text_api = IAMAuthenticator('paste here') #paste your speech to text api key
         speech_to_text = SpeechToTextV1(authenticator=speech_to_text_api)
         speech_to_text.set_service_url('paste here') #paste your speech to text service url
         audio = askopenfilename(filetypes=[("mp3 file","*.mp3")])
         try:
                 with open(audio,"rb") as audio_file:
                         speech_to_text_results = speech_to_text.recognize(audio=audio_file,content_type='audio/mp3').get_result()
                 result_s_2_t='''<html><head></head><body><table style="width:100%" border="1"><tr><th><h3 style="color:red;font-family:Comic Sans MS">Classification</h3></th><th><h3 style="color:red;font-family:Comic Sans MS">Confident\nScore<h3></th></tr>'''
                 for result in speech_to_text_results["results"]:
                         for classification in result:
                                 if classification != "final":
                                         result_s_2_t=result_s_2_t+f'<tr><td><center><h3 style="color:blue;font-family:Comic Sans MS">{result[classification][0]["transcript"]}</h3> </center></td><td><center><h3 style="color:blue;font-family:Comic Sans MS"> {str(round(result[classification][0]["confidence"]*100))}%</h3> </center></td></tr>'
                 result_s_2_t=result_s_2_t+f'</table></body></html>'
                 result_loc = ttk.Label(master,text= "Result")
                 clear_loc_btm=Button(master,text="Clear result",bg="black",fg="white")
                 result_loc["font"] = font.Font(family='Comic Sans MS', size=15, weight='bold',underline = True )
                 frame_loc = HtmlFrame(master,horizontal_scrollbar="auto",vertical_scrollbar="auto")
                 frame_loc.set_content(result_s_2_t)
                 clear_loc_btm["command"] = lambda one=result_loc, two=clear_loc_btm, three=frame_loc: self.clear(one,two,three)
                 clear_loc_btm["font"] = font.Font(family='Comic Sans MS', size=10,weight='bold')
                 clear_loc_btm.pack()
                 result_loc.pack()
                 frame_loc.pack(fill="x")
         except:
                 pass
示例#13
0
    def clickAboutButton(self):
        with open("resources/LICENSE.md") as license:
            about = tk.Toplevel(self.master)
            about.title("About")

            content = HtmlFrame(about)
            content.set_content(md.markdown(license.read()))
            content.grid()
示例#14
0
    def __init__(self, master):
        top = self.top = Toplevel(master)
        html_label = HtmlFrame(top,
                               horizontal_scrollbar="auto",
                               vertical_scrollbar=True)
        html_label.pack(fill="both", expand=True)
        html_label.set_content(main.html)

        self.b = Button(top, text='Esci', command=self.cleanup)
        self.b.pack()
示例#15
0
 def popupmsg(self, monster_name, html):
     popup = Tk()
     popup.wm_title(monster_name)
     html_label = HtmlFrame(popup,
                            horizontal_scrollbar="auto",
                            vertical_scrollbar=True)
     html_label.pack(fill="both", expand=True)
     html_label.set_content(html)
     B1 = ttk.Button(popup, text="Close", command=popup.destroy)
     B1.pack()
     popup.mainloop()
def displayresult():
    frame = HtmlFrame(gtuapp,
                      horizontal_scrollbar="auto",
                      vertical_scrollbar="auto",
                      width=500,
                      height=500)
    frame.set_content(r.content)
    frame.pack(expand='yes', fill='both')

    global MyButton2
    MyButton2 = Button(frame, text="Back", width=10, command=frame.destroy)
    MyButton2.place(x=0, y=0)
示例#17
0
def open_about_window():
    """Opens About window, which displays README.md."""
    about_window = Toplevel(root)

    about_window.title("About")

    dir_path = os.path.dirname(os.path.realpath(__file__))

    with open(os.path.join(dir_path, 'README.md')) as readme:
        text = readme.read()
    html_readme = markdown.markdown(text)
    frm_readme = HtmlFrame(about_window, horizontal_scrollbar="auto")
    frm_readme.grid(sticky=tk.NSEW)
    frm_readme.set_content(html_readme)
示例#18
0
def open_contact_window():
    """Opens Contact window, which displays contact info."""
    contact_window = Toplevel(root)
    contact_window.title("Contact")

    text = '''
           Please direct your comments and suggestions to this email:
           [email protected]

           You can also open issues or create pull requests in this github repository:
           github.com/ceferisbarov/ANL-book-retriever/
           '''
    html_contact = markdown.markdown(text)
    frm_contact = HtmlFrame(contact_window, horizontal_scrollbar="auto")
    frm_contact.grid(sticky=tk.NSEW)
    frm_contact.set_content(html_contact)
示例#19
0
    def stats_click(self):
        self.LOG.debug('Clicked on show stats')
        try:
            html = Application.portfolio.df_history(tabulate_mode=True)

            top = self.create_top_level(title='Portfolio History Stats',
                                        geometry='620x400')

            hf = HtmlFrame(top)
            hf.pack()
            hf.set_content(html)

        except AttributeError:
            messagebox.showinfo('System Message',
                                'No history stats to show',
                                icon='error')
            self.LOG.exception('No history to show in stats')
            raise
示例#20
0
    def view_stocks_click(self):
        self.LOG.debug('Clicked on view stocks')
        try:
            html = self.portfolio.df_stocks(to_email=True)

            top = self.create_top_level(title='Stocks In Portfolio',
                                        geometry='685x255')

            hf = HtmlFrame(top)
            hf.pack()
            hf.set_content(html)

        except AttributeError:
            messagebox.showinfo('System Message',
                                'No stocks to show',
                                icon='error')
            self.LOG.exception('No stocks to show in view stocks')
            raise
示例#21
0
 def local_image_classify(self,tab2):
         img_file = askopenfilename(filetypes=[("Image files",("*.png","*.jpeg","*.jpg"))])                   
         vr_api = IAMAuthenticator("paste here") #paste your visual recognition API Key
         vr1=vr(version="2018-03-19",authenticator=vr_api)
         vr1.set_service_url("paste here") #paste your visual recognition your service URL
         try:
                 with open(img_file,"rb") as img:
                         loc_img_result=vr1.classify(images_file=img).get_result()
                 result_loc = ttk.Label(tab2,text= "Result")
                 clear_loc_btm=Button(tab2,text="Clear result",bg="black",fg="white")
                 result_loc["font"] = font.Font(family='Comic Sans MS', size=15, weight='bold',underline = True )
                 result_loc1='''<html><head></head><body><table style="width:100%" border="1"><tr><th><h2 style="color:red;font-family:Comic Sans MS">Classification</h2></th><th><h2 style="color:red;font-family:Comic Sans MS">Confident Score<h2></th></tr>'''
                 for i in range(len(loc_img_result["images"][0]["classifiers"][0]["classes"])):
                         result_loc1=result_loc1+f'<tr><td><center><h3 style="color:blue;font-family:Comic Sans MS">{loc_img_result["images"][0]["classifiers"][0]["classes"][i]["class"]}</h3> </center></td><td><center><h3 style="color:blue;font-family:Comic Sans MS"> {str(round(loc_img_result["images"][0]["classifiers"][0]["classes"][i]["score"]*100))}%</h3> </center></td></tr>'
                 result_loc1=result_loc1+f'</table></body></html>'
                 frame_loc = HtmlFrame(tab2,horizontal_scrollbar="auto",vertical_scrollbar="auto")
                 frame_loc.set_content(result_loc1)
                 clear_loc_btm["command"] = lambda one=result_loc, two=clear_loc_btm, three=frame_loc: self.clear(one,two,three)
                 clear_loc_btm["font"] = font.Font(family='Comic Sans MS', size=10,weight='bold')
                 clear_loc_btm.pack()
                 result_loc.pack()
                 frame_loc.pack()
         except:
                 pass
示例#22
0
link_5 = Button(frame1,
                text="Check Update..",
                font=tab_font,
                command=find_update,
                fg="blue",
                bg="#90B3DD",
                activeforeground="red",
                activebackground="#90B3DD",
                cursor="hand2",
                relief=FLAT,
                underline=0)
link_5.place(x=20, y=420)
link_5.config(highlightthickness=0)

frame2 = HtmlFrame(master=tab3, width=640,
                   horizontal_scrollbar="auto")  # Tab3_Frame2
frame2.pack(fill=tk.BOTH, side=tk.LEFT, expand=True)

frame2.set_content(open("assets/help.html", "r").read())

# ----------------------------Fast Youtube Search ----------------

cust_font = font = ('Consolas', 16)
width = 800
height = 500
img1 = Image.open("assets/ytsearchbg.png")
img1 = img1.resize((width, height), Image.ANTIALIAS)
photoImg1 = ImageTk.PhotoImage(img1)
wb1 = Label(tab5, image=photoImg1)
wb1.pack()
示例#23
0
from tkinter import *
from unidecode import unidecode
from tkinterhtml import HtmlFrame

from myfeedparser import MyFeedParser

window = Tk()
window.geometry("800x600")
window.title("Welcome to My Feed Parser")

frame = HtmlFrame(window,
                  horizontal_scrollbar="auto",
                  vertical_scrollbar="auto")
f = MyFeedParser()
s = f.getLatestFeedsAsHtml(True)

# Convert non-ascii characters to their best ascii representation
#print(s)
ascii = unidecode(s)

frame.set_content(ascii)

frame.pack(expand=True, fill="both")
#window.pack_propagate()

window.mainloop()
示例#24
0
 def text_to_speech(self,master):
         try:
                 def convert():
                         api_text_2_speech = IAMAuthenticator("paste here") #paste your text to speech api key
                         text_2_speech = TextToSpeechV1(authenticator=api_text_2_speech)
                         text_2_speech.set_service_url("paste here") #paste your text to speech service url
                         if var.get() == "male voice":
                                 try:
                                         audio_result = asksaveasfilename(defaultextension=".mp3",filetypes=[("mp3 file","*.mp3")])
                                         with open(audio_result,"wb") as audio:
                                                 audio.write(text_2_speech.synthesize(text,accept="audio/mp3",voice="en-US_HenryV3Voice").get_result().content)
                                                 audio.close()
                                         messagebox.showinfo("Done","Your text file is successfully converted into audio file. Your audio file saved in male voice at " + audio_result)
                                 except:
                                         pass
                         elif var.get() == "female voice":
                                 try:
                                         audio_result = asksaveasfilename(defaultextension=".mp3",filetypes=[("mp3 file","*.MP3")])
                                         with open(audio_result,"wb") as audio:
                                                 audio.write(text_2_speech.synthesize(text,accept="audio/mp3",voice="en-US_AllisonVoice").get_result().content)
                                                 audio.close()
                                         messagebox.showinfo("Done","Your text file is successfully converted into audio file. Your audio file is saved in female voice at " + audio_result)
                                 except:
                                         pass
                         
                         else:
                                 messagebox.showwarning(title="Voice Error", message=f'''Please select the voice and save again.''')
                         
                 def sel():
                         selection = "Your audio will be saved in " + str(var.get())
                         label.config(text = selection)
                 text_file = askopenfilename(filetypes=[("text file","*.txt")])
                 with open(text_file) as text_data:
                         text = text_data.read()
                 text_html = f'''<html><head></head><body><p>{text}</p></body><html>'''
                 result_loc = ttk.Label(master,text= "The Text")
                 clear_loc_btm=Button(master,text="Clear",bg="black",fg="white")
                 result_loc["font"] = font.Font(family='Comic Sans MS', size=15, weight='bold',underline = True )
                 frame_loc = HtmlFrame(master,horizontal_scrollbar="auto",vertical_scrollbar="auto")
                 frame_loc.set_content(text_html)
                 clear_loc_btm["font"] = font.Font(family='Comic Sans MS', size=12,weight='bold')
                 var = StringVar()
                 R1 = Radiobutton(master, text="Save as male voice", variable=var, value="male voice",command=sel)
                 R1["font"] = font.Font(family='Comic Sans MS', size=11)
                 R1.pack()
                 R2 = Radiobutton(master, text="Save as female voice", variable=var, value="female voice",command=sel)
                 R2["font"] = font.Font(family='Comic Sans MS', size=11)
                 R2.pack() 
                 label = ttk.Label(master)
                 label["font"] = font.Font(family='Comic Sans MS', size=11)
                 label.pack()
                 save_audio = Button(master,text="Save",bg="blue",fg="white",command=convert)
                 save_audio["font"] = font.Font(family='Comic Sans MS', size=11, weight='bold')
                 save_audio.pack()
                 em = ttk.Label(master)
                 em.pack()
                 clear_loc_btm["command"] = lambda one=result_loc, two=clear_loc_btm, three=frame_loc, four=R1, five=R2, six=label, seven = save_audio,egith = em: self.clear(one,two,three,four,five,six,seven,egith)
                 clear_loc_btm.pack()
                 result_loc.pack()
                 frame_loc.pack(fill="x")
         except:
                 pass
示例#25
0
# -*- coding=utf-8 -*-
import urllib

try:
    import tkinter as tk
except ImportError:
    import Tkinter as tk

from tkinterhtml import HtmlFrame

root = tk.Tk()

frame = HtmlFrame(root, horizontal_scrollbar="auto")
frame.grid(sticky=tk.NSEW)

frame.set_content("""
<html>

<head>
<meta name=标题 content="">
<meta name=关键词 content="">
<meta http-equiv=Content-Type content="text/html; charset=x-mac-chinesesimp">
<meta name=Generator content="Microsoft Word 14 (filtered)">
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:宋体;
示例#26
0
    htmltext += "</body></html>"
    htmltext = htmltext.replace("<table>",'<table border="2" >')
    htmltext = htmltext.replace("<code>",'<code bgcolor="#DCDCDC" >')
    # print(htmltext)
    preview.set_content(htmltext)
    print(event_r.keysym)
    if "Control" not in event_r.keysym:
        print("Control is not pressed.")
        saved = 0
        refreshtitle()

#---
markdowncode_box.bind("<Key>", refreshth)
#---
root.bind_all('<Control-s>', savef)
root.bind_all('<Control-S>', saveasf)
root.bind_all('<Control-o>', openf)
root.bind_all('<Control-q>', askexit)
root.bind_all('<Control-e>', htmlasf)
root.bind_all('<Control-b>', boldt)
root.bind_all('<Control-i>', italict)
root.bind_all('<Control-h>', helpwin)
root.bind_all('<Control-n>', newf)
#---
preview = HtmlFrame(htmlpreview, horizontal_scrollbar="auto")
preview.pack(expand=True, fill="both")

root.protocol("WM_DELETE_WINDOW", askexit)

root.mainloop()
示例#27
0
# -*- coding=utf-8 -*-
import urllib

try:
    import tkinter as tk
except ImportError:
    import Tkinter as tk

from tkinterhtml import HtmlFrame

root = tk.Tk()

frame = HtmlFrame(root, horizontal_scrollbar="auto")
frame.grid(sticky=tk.NSEW)

frame.set_content("""
<html>

<head>
<meta name=标题 content="">
<meta name=关键词 content="">
<meta http-equiv=Content-Type content="text/html; charset=x-mac-chinesesimp">
<meta name=Generator content="Microsoft Word 14 (filtered)">
<style>
<!--
 /* Font Definitions */
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:宋体;
示例#28
0
        for submission in subreddit.stream.submissions(
        ):  # REFRESH AND LOOK FOR NEW POSTS AND PROCESS THEM
            try:
                h = submission.title.lower().find('[h]')
                w = submission.title.lower().find('[w]')
                if w > h:
                    want = submission.title.lower().split('[w]')[1]
                else:
                    want = submission.title.lower().split('[h]')[0]
            except:
                continue

            if 'paypal' in want.lower():  # aka if it's a selling post

                html = f'<html><body>{markdown2.markdown(submission.selftext)}</body></html>'
                frame = HtmlFrame(root, horizontal_scrollbar="auto")
                frame.grid(sticky=tk.NSEW)
                frame.set_content(html)
                root.columnconfigure(0, weight=1)
                root.rowconfigure(0, weight=1)
                root.update_idletasks()
                root.update()

                # CREATE INSTANCE OF CLASS HWSPOST, GIVE IT ATTRIBUTES OF TITLE, BODY, URL.
                try:
                    post_title = submission.title.split('[H]')[1].split(
                        '[W]')[0]
                    post_body = submission.selftext.replace(
                        ',', '')  # Remove ',' in price tags
                    post_url = submission.url.strip()
                    post_author = submission.author
示例#29
0
    if (check == True):
        messagebox.showinfo(title="아님!", message="XML 형식이 아님!")
        return False
    else:
        return True


window = tkinter.Tk()

window.title("BY. sy")
window.geometry("240x60")
window.resizable(False, False)
frame1 = tkinter.Frame(window, relief="solid", bd=2)
frame2 = tkinter.Frame(window, relief="solid", bd=2)
frame3 = tkinter.Frame(window, relief="solid", bd=2)
htmlviewr = HtmlFrame(frame3, horizontal_scrollbar="auto")
submit = tkinter.Button(frame1,
                        width=30,
                        heigh=5,
                        text="결과 제출",
                        command=lambda: btn_pressed('1'))
psubmit = tkinter.Button(frame1,
                         width=30,
                         heigh=5,
                         text="붙여널고 결과 제출\n(AutoPaste)",
                         command=lambda: btn_pressed('2'))
result = tkinter.Label(frame1,
                       width=30,
                       heigh=5,
                       text="여기에\n결과가\n표시됩니다",
                       relief="solid",
示例#30
0
import urllib.request
try:
    import tkinter as tk
except ImportError:
    import Tkinter as tk

from tkinterhtml import HtmlFrame

root = tk.Tk()

frame = HtmlFrame(root, horizontal_scrollbar="auto")
frame.grid(sticky=tk.NSEW)

root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)

frame.set_content("""
<html>
<body>
<h1>Hello world!</h1>
<p>First para</p>
<ul>
    <li>first list item</li>
    <li>second list item</li>
</ul>
</body>
</html>    
""")

frame.set_content(
    urllib.request.urlopen("http://tkhtml.tcl.tk/").read().decode())
示例#31
0
import urllib.request
try:
    import tkinter as tk
except ImportError:
    import Tkinter as tk

from tkinterhtml import HtmlFrame

root = tk.Tk()

frame = HtmlFrame(root, horizontal_scrollbar="auto")
frame.grid(sticky=tk.NSEW)

frame.set_content("""
<html>
<body>
<h1>Hello world!</h1>
<p>First para</p>
<ul>
    <li>first list item</li>
    <li>second list item</li>
</ul>
<img src="http://findicons.com/files/icons/638/magic_people/128/magic_ball.png"/>
</body>
</html>    
""")

frame.set_content(
    urllib.request.urlopen("http://thonny.cs.ut.ee").read().decode())
#print(frame.html.cget("zoom"))
class Application(Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()

        # Global vars
        self.messages = []

        # Create Widgets
        self.btn_connect = Button(self, text="Connect", command=self.connect)
        self.chat_messages = HtmlFrame(self, horizontal_scrollbar="auto")
        self.message_entry_value = StringVar()
        self.message_entry = Entry(self, textvariable=self.message_entry_value)
        self.btn_send_msg = Button(self, text="Send", command=self.send_msg)
        self.label_status = Label(self, text="Disconnected")

        # Pack widgets
        self.pack_widgets()

    def pack_widgets(self):
        self.btn_connect.pack(side="top")
        self.chat_messages.pack(side="bottom")
        self.message_entry_value.set("")
        self.message_entry.pack(side="bottom")
        self.btn_send_msg.pack(side="bottom")
        self.label_status.pack(side="bottom")

    def connect(self):
        self.label_status['text'] = "Connecting..."

        try:
            # Connect to the gateway
            sio = socketio.Client()
            sio.connect('http://localhost:5000', namespaces=['/chat'])
            self.label_status['text'] = "Connected. SID : " + sio.sid

            # Event listeners
            register(LocalEvents.EVENT_MESSAGE_ADDED, lambda event: self.on_message_added(event.data))

            # Register namespaces
            sio.register_namespace(ChatSocketHandler('/chat'))
        except Exception as e:
            self.label_status['text'] = e

    def send_msg(self):
        dispatch(Event(LocalEvents.EVENT_MESSAGE_SEND, self.message_entry_value.get()))
        self.message_entry_value.set("")

    def on_message_added(self, data):
        self.messages.append(data)

        chat_messages = ""

        for message in self.messages:
            chat_messages = markdown.markdown(
                "**" + message['user_id'] + "**: " + message['message'] + '\n'
            ) + chat_messages

        self.chat_messages.set_content("""
            <html>
                <body style="font-size: 20px;">
                    {0}
                </body>
            </html>    
        """.format(chat_messages))
示例#33
0
# Second paned window to hold html and images
#
pw2 = PanedWindow(pw1, orient=VERTICAL, height=500)
pw1.add(pw2)
#
# Add image editor to PanedWindow 2
#
f2 = Canvas(pw2, width=100, height=500,
            background="light grey")  # make canvas for drawing
f2.pack(side='top', expand='yes')
image_id = f2.create_image(0, 0, image=im, anchor="nw")
pw2.add(f2)
#
# add html window to PanedWindow 2
#
f3 = HtmlFrame(root, horizontal_scrollbar="auto", height=100, width=100)
# f3.pack(side='top', fill='x', expand='no')
pw2.add(f3)
#
# Setup
#
lastx, lasty = None, None
try:
    image1 = PIL.Image.open("image_0.png")
except:
    image1 = PIL.Image.new('RGB', (500, 480), 'grey')
global draw
draw = ImageDraw.Draw(image1)
#
# f1.grid_rowconfigure(0, weight=1)
# f1.grid_columnconfigure(0, weight=1)
示例#34
0
class RssEnterprise():
    def __init__(self):
        self.root = tk.Tk()
        self.root.geometry("1000x700")
        self.root.title('RSS Enterprise')
        # self.root.iconbitmap("/home/stef/Python/rss_enterprise/icon.ico")

        self.settings_folder_path = os.path.join(Path.home(),
                                                 '.rss_enterprise')

        self.assert_settings()

        with open(self.get_cache_path(), mode='a') as self.fp_cache:
            top_frame = Frame(self.root)
            top_frame.pack(fill=BOTH, expand=True)

            bottom_frame = Frame(self.root)
            bottom_frame.pack(fill=BOTH, expand=True)

            self.tree = ttk.Treeview(top_frame,
                                     selectmode='browse',
                                     columns=(
                                         'title',
                                         'feed',
                                         'published',
                                     ))
            self.refresh_list()

            scrollbar_tree = ttk.Scrollbar(top_frame,
                                           orient="vertical",
                                           command=self.tree.yview)
            self.tree.configure(yscrollcommand=scrollbar_tree.set)
            self.tree.bind("<<TreeviewSelect>>", self.on_tree_select)
            self.tree.bind('<Return>', self.open_current_weblink)
            self.tree.heading('#0', text='title', anchor=tk.CENTER)
            self.tree.heading('#1', text='feed', anchor=tk.CENTER)
            self.tree.heading('#2', text='published', anchor=tk.CENTER)

            self.tree.column('#0', stretch=tk.YES, minwidth=50, width=630)
            self.tree.column('#1', stretch=tk.YES, minwidth=50, width=150)
            self.tree.column('#2', stretch=tk.YES, minwidth=50, width=200)

            scrollbar_tree.pack(side='right', fill='y')
            self.tree.pack(fill=BOTH, expand=True)

            self.text = HtmlFrame(self.root,
                                  fontscale=1.2,
                                  horizontal_scrollbar="auto")
            self.text.pack(fill=BOTH, expand=True)

            self.root.mainloop()

    def assert_settings(self):
        if not os.path.isdir(self.settings_folder_path):
            os.mkdir(self.settings_folder_path)

        if not os.path.isfile(self.get_feeds_path()):
            copyfile(os.path.join('test', 'feeds.txt'), self.get_feeds_path())

        if not os.path.isfile(self.get_cache_path()):
            with open(self.get_cache_path(), mode="w") as fp:
                fp.write('')

    def open_current_weblink(self, event):
        id = self.tree.selection()[0]
        self.open_link(id)

    def get_feeds_path(self):
        return os.path.join(self.settings_folder_path, 'feeds.txt')

    def get_cache_path(self):
        return os.path.join(self.settings_folder_path, 'cache')

    def load_feeds(self, feeds_path):
        print('loading feeds')
        with open(feeds_path, 'r') as fp:
            feeds = [
                l.strip() for l in fp.read().splitlines() if l.strip() != ''
            ]
            return feeds

    def add_line_to_cache(self, line):
        self.fp_cache.write(line + '\n')

    def load_feed(self, feeds, feed_url):
        print('start loading ', feed_url)
        result = feedparser.parse(feed_url)
        if result['status'] == 404:
            print(feed_url, 'was not found')
        else:
            feeds.append(result)

    def load_news_items(self, feed_urls):
        print('loading news items')

        feeds = []

        threads = [
            Thread(target=self.load_feed, args=(feeds, feed_url))
            for feed_url in feed_urls
        ]

        [t.start() for t in threads]
        [t.join() for t in threads]

        entries = []

        for feed in feeds:
            for i in feed["items"]:
                i['channel_title'] = feed['channel']['title']
                try:
                    i['formatted_date'] = parse(i['published'])
                    print(i['published'])
                except KeyError:
                    i['formatted_date'] = parse(i['updated'])
                    print(i['updated'])

                if i['formatted_date'].tzinfo is None or i[
                        'formatted_date'].tzinfo.utcoffset(
                            i['formatted_date']) is None:
                    i['formatted_date'] = i['formatted_date'].replace(
                        tzinfo=pytz.utc)

            entries.extend(feed["items"])

        sorted_entries = sorted(entries, key=lambda entry: i['formatted_date'])
        sorted_entries.reverse()

        return sorted_entries

    def refresh_list(self):
        with open(self.get_cache_path(), 'r') as fp:
            cache = fp.read().splitlines()

        feeds = self.load_feeds(self.get_feeds_path())
        all_news_items = self.load_news_items(feeds)
        for i in all_news_items:
            try:
                if i['link'] not in cache:
                    self.tree.insert('',
                                     'end',
                                     i['link'],
                                     text=i['title'],
                                     values=(
                                         i['channel_title'],
                                         i['formatted_date'],
                                         i['summary'],
                                     ))
            except (TclError, KeyError):
                # in case of double entries, or entries without a link, we just forget about them
                pass

    def on_tree_select(self, event):
        id = self.tree.selection()[0]
        summary = self.tree.item(id, "values")[2]
        self.set_input(summary)
        self.add_line_to_cache(id)

    def open_link(self, link):
        # works only on linux
        subprocess.Popen(['xdg-open', link])
        sleep(0.5)
        subprocess.Popen([
            'wmctrl',
            '-a',
            'RSS Enterprise',
        ])

    def set_input(self, value):
        self.text.set_content(value)