コード例 #1
1
    def show(self):
        if self.class_:
            self.root = Toplevel(slef.master, class_=self.class_)
        else:
            self.root = Toplevel(self.master)
        
        self.root.title(self.title)
        self.root.iconname(self.title)
        
        self.frame = Frame(self.root, padx=5, pady=5)

        self.stf = Frame(self.frame)
        
        stext = ScrolledText(self.stf, bg='white', height=20, width=120)
        stext.insert(END, self.text)
        stext.pack(fill=BOTH, side=LEFT, expand=True)
        stext.focus_set()

        self.stf.pack(expand=True, fill=BOTH)
        self.frame.pack(expand=True, fill=BOTH)
        self.root.bind('<Return>', self.return_evt)
        
        b = Button(self.frame, text='Close', width=10,
                   command=self.wm_delete_window)
        b.pack(side=TOP, pady=5)
        
        self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)
        self._set_transient(self.relx, self.rely)
        self.root.wait_visibility()
        self.root.grab_set()
        self.root.mainloop()
        self.root.destroy()
コード例 #2
1
ファイル: twisted_example.py プロジェクト: rik0/rk-exempla
class ChatWindow(object):
    def __init__(self, parent, line_sender):
        self.parent = parent
        self.main = self.build_window()
        self.line_sender = line_sender

    def build_window(self):
        self.toplevel = tk.Toplevel(self.parent)
        f = tk.Frame(self.toplevel)
        f.pack()
        
        self.area = ScrolledText(f)
        self.area.pack(side=tk.TOP)
        self.area.config(state=tk.DISABLED)

        self.line = tk.Entry(f)
        self.line.pack(side=tk.BOTTOM, padx=10, pady=10)
        self.line.focus_force()

        self.toplevel.bind('<Return>', self.send_line)
        return f

    def send_line(self, _evt):
        line = self.line.get()
        self.line.delete(0, tk.END)
        self.line_sender(line)

    def add_message(self, msg):
        self.area.config(state=tk.NORMAL)
        self.area.insert(tk.END, '%s\n' % msg)
        self.area.config(state=tk.DISABLED)

    def set_dispose_callback(self, callback):
        self.toplevel.protocol('WM_DELETE_WINDOW', callback)
コード例 #3
0
    def open_text(self):
        if self.selected_text_title != "[]":

            text_root = tk.Tk()
            popup = tk.Menu(text_root, tearoff=0)
            textWindow = ScrolledText(text_root, wrap="word")
            uw_list = self.uw_lb.get(0, tk.END)
            text_root.bind(
                "<Button-1>", lambda eff: meaning_part(
                    eff, T=textWindow, unknown_words_list=uw_list, popup=popup)
            )
            textWindow.insert(1.0,
                              general_dict["Text"][self.selected_text_title])
            textWindow.tag_config("A", foreground="red", background="white")
            textWindow.pack(expand=True, fill=tk.BOTH)
            for word in general_dict["Unknown"][self.selected_text_title]:
                word = " " + word + " "
                start = 1.0
                search_pos = textWindow.search(word, start, stopindex=tk.END)

                while search_pos:
                    length = len(word)
                    row, col = search_pos.split('.')
                    end = int(col) + length
                    if str(end)[-1] == "0":
                        end += 1

                    end = row + '.' + str(end)

                    textWindow.tag_add("A", search_pos, float(end))
                    start = end
                    search_pos = textWindow.search(word,
                                                   start,
                                                   stopindex=tk.END)
コード例 #4
0
    def open_text(self):
        if self.selected_text_title != "[]":

            text_root = tk.Tk()
            textWindow = ScrolledText(text_root, wrap="word")
            textWindow.insert(1.0,
                              general_dict["Text"][self.selected_text_title])
            textWindow.tag_config("A", foreground="red", background="white")
            textWindow.pack(expand=True, fill=tk.BOTH)
            for word in general_dict["Unknown"][self.selected_text_title]:
                word = " " + word + " "
                start = 1.0
                search_pos = textWindow.search(word, start, stopindex=tk.END)

                while search_pos:
                    length = len(word)
                    row, col = search_pos.split('.')
                    end = int(col) + length
                    if str(end)[-1] == "0":
                        end += 1

                    end = row + '.' + str(end)

                    textWindow.tag_add("A", search_pos, float(end))
                    start = end
                    search_pos = textWindow.search(word,
                                                   start,
                                                   stopindex=tk.END)
コード例 #5
0
    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent

        self.parent.title("Twitter Judge")
        self.style = Style()
        self.style.theme_use("default")

        output_frame = Frame(self, relief = RIDGE, borderwidth = 1)
        output_frame.pack(anchor = N, fill = BOTH, expand = True)

        output_text = ScrolledText(output_frame)
        self.output_text = output_text
        output_text.pack(fill = BOTH, expand = True)

        input_frame = Frame(self, height = 32)
        input_frame.pack(anchor = S, fill = X, expand = False)

        user_label = Label(input_frame, text = "Enter username:"******"Judge!", command = lambda: judge(user_entry.get(), self))
        judge_button.pack(side = RIGHT)
        user_entry = Entry(input_frame)
        user_entry.pack(fill = X, padx = 5, pady = 5, expand = True)

        self.pack(fill = BOTH, expand = True)
コード例 #6
0
class ChatWindow(object):
    def __init__(self, parent, line_sender):
        self.parent = parent
        self.main = self.build_window()
        self.line_sender = line_sender

    def build_window(self):
        self.toplevel = tk.Toplevel(self.parent)
        f = tk.Frame(self.toplevel)
        f.pack()

        self.area = ScrolledText(f)
        self.area.pack(side=tk.TOP)
        self.area.config(state=tk.DISABLED)

        self.line = tk.Entry(f)
        self.line.pack(side=tk.BOTTOM, padx=10, pady=10)
        self.line.focus_force()

        self.toplevel.bind('<Return>', self.send_line)
        return f

    def send_line(self, _evt):
        line = self.line.get()
        self.line.delete(0, tk.END)
        self.line_sender(line)

    def add_message(self, msg):
        self.area.config(state=tk.NORMAL)
        self.area.insert(tk.END, '%s\n' % msg)
        self.area.config(state=tk.DISABLED)

    def set_dispose_callback(self, callback):
        self.toplevel.protocol('WM_DELETE_WINDOW', callback)
コード例 #7
0
ファイル: ImageD11_gui.py プロジェクト: yns11/tst
 def history(self):
     from ScrolledText import ScrolledText
     win = ScrolledText(Toplevel(), width=100)
     history = self.guicommander.gethistory()
     win.insert(END, history)
     win.pack(expand=1, fill=BOTH)
     win.focus_set()
コード例 #8
0
def run(event):
    """Run the script and shows the resulting HTML code in a
    new window
    If started with the "Make HTML" button, saves HTML output in
    a file"""
    pythonCode=pythonText.get(1.0,END)
    lines=pythonCode.split('\n')
    lines=map(lambda x:x[5:],lines)
    pythonCode='\n'.join(lines)
    execWindow=Toplevel()
    execText=ScrolledText(execWindow,width=40,height=40,bg="white",
        font=FONT)
    execText.pack()
    s=sys.stdout
    sys.stdout=Output(execText)
    try:
        exec(pythonCode) in globals()
        if event.widget is bRunHTML:
            htmlFilename=os.path.splitext(pihText.filename)[0]+".htm"
            if os.path.exists(htmlFilename):
                override=tkMessageBox.askyesno("Override ?",
                    "File %s already exists - Override ?" \
                    %os.path.basename(htmlFilename))
                if not override:
                    return
            f=open(htmlFilename,"w")
            f.write(execText.get(1.0,END))
            f.close()
            path=os.path.join(os.getcwd(),htmlFilename)
            webbrowser.open_new("file://"+path)
    except:
        traceback.print_exc(file=sys.stdout)
    sys.stdout=s
コード例 #9
0
ファイル: _bayestest.py プロジェクト: jcstroud/keres
def _bayestest():
  logging.basicConfig(level=logging.INFO,
                      stream=sys.stdout)
  logging.basicConfig(level=logging.DEBUG,
                      stream=sys.stdout)
  logging.root.level = 30
  tk = Tk.Tk()
  tk.title('BayesTest')
  stopper = make_stopper(tk)
  tk.protocol("WM_DELETE_WINDOW", stopper)
  tk.info = Tk.Label(tk, text="BayesTest Main Window")
  tk.info.pack(expand=Tk.NO, fill=Tk.BOTH)
  time.sleep(0.1)
  ip = ScrolledText(tk, relief=Tk.SUNKEN, border=2)
  ip.pack(expand=Tk.YES, fill=Tk.BOTH)
  tk.info_pane = ip
  tk.status = Tk.Label(tk, text="...")
  tk.status.pack(expand=Tk.NO, fill=Tk.BOTH)
  tk.subprog = Tk.Label(tk, text="")
  tk.subprog.pack(expand=Tk.NO, fill=Tk.BOTH)
  Tk.Button(tk, text="Quit", command=stopper).pack()
  docalcs(tk)
  tk.tkraise()
  tk.update_idletasks()
  tk.mainloop()
コード例 #10
0
 def __init__(self, tkRoot, app, masterComp, parentNode, logger):
     BaseView.__init__(self, tkRoot, app, logger)
     # master (upper level view) component on which this view was issued
     self.masterComp = masterComp
     
     self.parentNode = parentNode
                          
     self.window = Toplevel(self.tkRoot)
     self.window.title("%s" % parentNode.keyForIsObject)
     
     # self.window.bind("<<close-window>>", self.__onClose) # doesn't work
     self.window.protocol("WM_DELETE_WINDOW", self.__onClose)
     
     text = ScrolledText(self.window, width = RobView.GUI_WIDTH,
                         height = RobView.GUI_HEIGHT, background='white')
     text.pack(fill = Y)
     
     # information from ROB (DataChannel) IS object (criteria results)
     # .valueOfIsObject is a bit misleading since it's criteria results
     # checks based on particular values (attributes) within the IS object
     m = ("ROB '%s':\n\n%s" %
          (parentNode.keyForIsObject, parentNode.valueOfIsObject))
     text.insert(END, m)
     
     text.configure(state = DISABLED) # disable edit now, not before insert
     
     # need to store this view under full name (not only under 
     # self.masterComp.name as the other views), since there may be 
     # a number of views named e.g. 'DataChannel0'
     self.app.addActiveView(self.parentNode.keyForIsObject, self)
コード例 #11
0
ファイル: ErrDialog.py プロジェクト: jfmc/logen
class ErrDialog(Dialog):
    def __init__(self,master=None, Title="Error", Short="",Msg=""):
        self.Title=Title
        self.Msg=Msg
        self.Short = Short
        Dialog.__init__(self,parent=master,title=Title)
        
        
    def body(self,unused):
        self.text = ScrolledText(self)
        self.text["height"] = "8"
        self.text["width"] = "50"
        
        self.text.pack(side="top",expand="yes",fill="both")
        self.text.insert("0.0", self.Msg)
        self.text["state"] = "disabled"
        self.result = False

    def buttonbox(self):
        box = Frame(self)

        w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
        w.pack(side=LEFT, padx=5, pady=5)

        self.bind("<Return>", self.ok)

        box.pack()
コード例 #12
0
ファイル: sdialogue.py プロジェクト: weikang9009/stars
class Credits(tkSimpleDialog.Dialog):
    def body(self, master):
        self.image = Tk.PhotoImage(file=GIFFILE)
        self.icon = Tk.Label(master, image=self.image)
        self.icon.pack(side=Tk.TOP)
        label = Tk.Label(master, text=crnotice1)
        label.pack(side=Tk.TOP)
        font = "Helvetica " + TITLEFONTSIZE
        label = Tk.Label(master,
                         font=font,
                         text="Credits",
                         justify=Tk.CENTER,
                         foreground='blue')
        label.pack(side=Tk.TOP)
        font = "Helvetica " + AXISFONTSIZE
        self.infoText = ScrolledText(master,
                                     relief=Tk.FLAT,
                                     padx=3,
                                     pady=3,
                                     background='white',
                                     foreground="blue",
                                     wrap='word',
                                     width=70,
                                     height=12,
                                     font=font,
                                     tabs=("4c"))
        self.infoText.pack(expand=0, fill=Tk.X, side=Tk.BOTTOM)
        self.infoText.delete('0.0', Tk.END)
        self.infoText.insert('0.0', getCredits())
        self.infoText.configure(state=Tk.DISABLED)
コード例 #13
0
ファイル: tk_app.py プロジェクト: YQS/eXMLorer
	def textFieldConstructor(self, labelText, value):
		def selectAllText(event):
			xField = event.widget
			xField.tag_add(SEL, '1.0', 'end')
			xField.mark_set(INSERT, "1.0")
			xField.see(INSERT)
			return 'break'
			
		#Label(self.body, text=labelText).grid(row=0, column=0, sticky='nw')
		Label(self.body, text=labelText).pack(side=TOP)
		
		#xTextbox = Text(self.body) ## ver que width y height poner
		xTextbox = ScrollText(self.body)
		#xTextbox.bind('<KeyRelease>', lambda event: apply())
		xTextbox.bind('<Control-Key-a>', lambda event: selectAllText(event) )
		xTextbox.bind('<Control-Key-A>', lambda event: selectAllText(event) )
		#xTextbox.grid(row=1, column=0, sticky='nw')
		xTextbox.pack(side=BOTTOM, fill=BOTH, expand=True)
		xTextbox.insert('1.0', value)
		self.entries[labelText] = xTextbox
		if self.firstField == None:
			self.firstField = xTextbox
			
		#SQL buttons from module
		params = {'parent':self.upper, 'field':self.firstField}
		MOD.runModules('TOPLEVEL', params)
コード例 #14
0
class ErrDialog(Dialog):
    def __init__(self, master=None, Title="Error", Short="", Msg=""):
        self.Title = Title
        self.Msg = Msg
        self.Short = Short
        Dialog.__init__(self, parent=master, title=Title)

    def body(self, unused):
        self.text = ScrolledText(self)
        self.text["height"] = "8"
        self.text["width"] = "50"

        self.text.pack(side="top", expand="yes", fill="both")
        self.text.insert("0.0", self.Msg)
        self.text["state"] = "disabled"
        self.result = False

    def buttonbox(self):
        box = Frame(self)

        w = Button(box, text="OK", width=10, command=self.ok, default=ACTIVE)
        w.pack(side=LEFT, padx=5, pady=5)

        self.bind("<Return>", self.ok)

        box.pack()
コード例 #15
0
ファイル: TraceFrame.py プロジェクト: Nadjet12/mots_croises
class TraceFrame(Frame):

    def __init__(self, *args, **kwargs):
        Frame.__init__(self, *args, **kwargs)

        self.t = ScrolledText(self, wrap="word")
        self.t.configure(background="light cyan")
        self.t.configure(height = 10)
        self.t.tag_config("in", foreground="forest green")
        self.t.tag_config("err", foreground="orange red")
        self.t.tag_config("time", foreground="sea green")
        self.t.tag_config("curr", foreground="black")
        self.t.tag_config("out", foreground="firebrick")
        self.t.pack(side="top", fill="both", expand=True)



    def add_To_Trace(self, st, tag):
        '''
        :param st: txte a afficher
        :param tag:  type de texte a afficher
        :return:
        '''
        self.t.insert(INSERT, st, tag)
        self.t.see(END)

    def clear_Trace(self):
        '''
        Efface la zone de texte
        :return:
        '''
        self.t.delete('1.0', 'end')
コード例 #16
0
 def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)
     self.controller = controller
     label = tk.Label(self, text="New Case",font=40)
     label.pack(side='left')
     
     sidebar = Frame(self, width=200, bg='white', height=500, relief='sunken', borderwidth=2)
     sidebar.pack(expand=True, fill='y', side='left', anchor='nw')
     
     label = tk.Label(sidebar, text="Case Name",font=40)
     label.pack(expand=True, fill='both')
     
     
     
     global entry
     entry= tk.Entry(sidebar)
     entry.pack(expand=True, fill='both')
     
     label = tk.Label(sidebar, text="Add Desciption",font=40)
     label.pack(expand=True, fill='both')
     
     global text
     text = ScrolledText(sidebar, undo=True,height=20)
     text['font'] = ('consolas', '12')
     text.pack(expand=True, fill='both')
     
     button = tk.Button(sidebar, text="Create",
                        command=lambda:insert(),font=40)
     button.pack(expand=True, fill='both')
     
     button = tk.Button(sidebar, text="Next>>",
                        command=lambda:controller.show_frame("PageTwo"),font=40)
 
     button.pack(side="right")
コード例 #17
0
ファイル: tkui.py プロジェクト: v-legoff/accertin
class Autotyper:
    """
  Autotyper class, it generates the autotyper window, waits for entering text
  and then calls a function to work with the text.
  """
    def __init__(self, master, sendfunc):
        """
    Initializes the autotyper.
    
    @param master: the main tk window
    @type  master: Tk

    @param sendfunc: the callback function
    @type  sendfunc: function
    """
        self._sendfunc = sendfunc

        self._frame = Toplevel(master)

        # self._frame.geometry("400x300")
        self._frame.title("Lyntin -- Autotyper")

        self._frame.protocol("WM_DELETE_WINDOW", self.cancel)

        if os.name == "posix":
            fontname = "Courier"
        else:
            fontname = "Fixedsys"
        fnt = tkFont.Font(family=fontname, size=12)

        self._txt = ScrolledText(self._frame,
                                 fg="white",
                                 bg="black",
                                 font=fnt,
                                 height=20)
        self._txt.pack(side=TOP, fill=BOTH, expand=1)

        self._send_btn = Button(self._frame, text="Send", command=self.send)
        self._send_btn.pack(side=LEFT, fill=X, expand=0)

        self._cancel_btn = Button(self._frame,
                                  text="Cancel",
                                  command=self.cancel)
        self._cancel_btn.pack(side=RIGHT, fill=X, expand=0)

    def send(self):
        """
    Will be called when the user clicks on the 'Send' button.
    """
        text = fix_unicode(self._txt.get(1.0, END))
        self._sendfunc(text)
        self._frame.destroy()

    def cancel(self):
        """
    Will be called when the user clicks on the 'Cancel' button.
    """
        self._sendfunc(None)
        self._frame.destroy()
 def browser(self, filename):
     new  = Toplevel()                                # make new window
     text = ScrolledText(new, height=30, width=90)    # Text with scrollbar
     text.config(font=('courier', 10, 'normal'))      # use fixed-width font
     text.pack()
     new.title("Text Viewer")                         # set window mgr attrs
     new.iconname("browser")
     text.insert('0.0', open(filename, 'r').read() )  # insert file's text
コード例 #19
0
 def __init__(self, master, text):
     Frame.__init__(self, master)
     text_field = ScrolledText(self)
     text_field.insert(At(0, 0), text)
     text_field.pack(side=TOP)
     text_field.config(state=DISABLED)
     ButtonBar(self, [], [('Close', self.master.destroy)]).pack(side=BOTTOM,
                                                                fill=X)
コード例 #20
0
ファイル: guimixin.py プロジェクト: qiupq/LearnPython
 def browser(self, filename):
     new = Toplevel()  # make new window
     text = ScrolledText(new, height=30, width=90)  # Text with scrollbar
     text.config(font=('courier', 10, 'normal'))  # use fixed-width font
     text.pack()
     new.title("Text Viewer")  # set window mgr attrs
     new.iconname("browser")
     text.insert('0.0', open(filename, 'r').read())  # insert file's text
 def browser(self, file):
     new  = Toplevel()
     text = ScrolledText(new, height=30, width=90)
     text.config(font=('Courier', 9, 'normal'))
     text.pack()
     new.title("Poor-man's Text Editor")
     new.iconname("PyBrowser")
     text.insert('0.0', open(file, 'r').read() )
 def browser(self, file):
     new = Toplevel()
     text = ScrolledText(new, height=30, width=90)
     text.config(font=('Courier', 9, 'normal'))
     text.pack()
     new.title("Poor-man's Text Editor")
     new.iconname("PyBrowser")
     text.insert('0.0', open(file, 'r').read())
コード例 #23
0
ファイル: ListWindows.py プロジェクト: qiupq/LearnPython
 def contViewRaw(self, msgnums):
     for msgnum in msgnums:  # could be a nested def
         fulltext = self.getMessage(msgnum)  # put in ScrolledText
         from ScrolledText import ScrolledText  # dont need full TextEditor
         window = windows.QuietPopupWindow(appname, 'raw message viewer')
         browser = ScrolledText(window)
         browser.insert('0.0', fulltext)
         browser.pack(expand=YES, fill=BOTH)
コード例 #24
0
class App(object):
    def __init__(self):
        self.root = tki.Tk()

        # create a Text widget with a Scrollbar attached
        self.txt = ScrolledText(self.root, undo=True)
        self.txt['font'] = ('consolas', '12')
        self.txt.pack(expand=True, fill='both')
コード例 #25
0
class PopupScrolledText(PopupWindow):
    """
    Scrolled text output window with 'Save As...'
    """

    def __init__(self, title="", kind="", iconfile=None, var=None):
        PopupWindow.__init__(self, title=title, kind=kind, iconfile=iconfile)
        if var:
            self._var = var
        else:
            self._var = BooleanVar()
        self._var.trace_variable("w", self._visibility_control)
        self._text = ScrolledText(self)
        self._text.pack()
        self._text.config(font=FONT)
        self._make_menu()
        self._visibility_control()

    def on_close(self, *args):
        self._var.set(False)

    def _visibility_control(self, *args):
        if self._var.get():
            self.deiconify()
        else:
            self.withdraw()

    def _make_menu(self):
        topmenu = Menu(self)
        self.config(menu=topmenu)
        file = Menu(topmenu, tearoff=0)
        file.add_command(label="Save as...", command=self.on_save_as)
        file.add_command(label="Hide", command=self.on_close)
        topmenu.add_cascade(label="File", menu=file)
        edit = Menu(topmenu, tearoff=0)
        edit.add_command(label="Clear text", command=self.on_clear)
        topmenu.add_cascade(label="Edit", menu=edit)

    def on_save_as(self):
        filename = asksaveasfilename()
        if filename:
            alltext = self.gettext()
            f = open(filename, "w")
            f.write(alltext)
            f.close()

    def on_clear(self):
        self._text.delete("0.0", END)
        self._text.update()

    def gettext(self):
        return self._text.get("1.0", END + "-1c")

    def hide(self):
        self._var.set(False)

    def show(self):
        self._var.set(True)
コード例 #26
0
 def __init__(self, parent, text, title="Phoshare Help"):
     Toplevel.__init__(self, parent)
     self.transient(parent)
     self.title(title)
     self.parent = parent
     t = ScrolledText(self)
     t.insert(END, text)
     t.config(state=DISABLED)
     t.pack()
コード例 #27
0
ファイル: tkmodule.py プロジェクト: lengdatou/datatk
class Toplevel_ScolledText(tk.Toplevel):
    def __init__(self, master=None, cnf={}, **kw):
        tk.Toplevel.__init__(self, master=None, cnf={}, **kw)
        self.__ShowText = ScrolledText(self,height = 20,width=40)
        self.__ShowText.pack(expand=1,fill='both')
        
    def addtext(self,Text_output=''):
        self.__ShowText.insert('end',Text_output)
        print(Text_output)
コード例 #28
0
class App(object):

    def __init__(self):
        self.root = tki.Tk()

    # create a Text widget with a Scrollbar attached
        self.txt = ScrolledText(self.root, undo=True)
        self.txt['font'] = ('consolas', '12')
        self.txt.pack(expand=True, fill='both')
コード例 #29
0
ファイル: xbb_help.py プロジェクト: BingW/biopython
class xbbtools_help(Toplevel):
    def __init__(self, *args):
        Toplevel.__init__(self)
        self.tid = ScrolledText(self)
        self.tid.pack(fill = BOTH, expand = 1)
        self.Styles()
        self.Show()

    def Styles(self):
        for c in ['red', 'blue', 'magenta', 'yellow', 'green', 'red4', 'green4', 'blue4']:
            self.tid.tag_configure(c, foreground = c)

        self.tid.tag_config('underline', underline =1)
        self.tid.tag_config('italic', font = ('Courier', 6, 'italic'))
        self.tid.tag_config('bold', font = ('Courier', 8, 'bold'))
        self.tid.tag_config('title', font = ('Courier', 12, 'bold'))
        self.tid.tag_config('small', font = ('Courier', 6, ''))
        self.tid.tag_config('highlight', background = 'gray')
        

    def Show(self):
        t = self.tid
        t.insert(END, "XBBtools Help\n", 'title')
        t.insert(END, """
Copyright 2001 by Thomas Sicheritz-Ponten.  All rights reserved.
This code is part of the Biopython distribution and governed by its
license.  Please see the LICENSE file that should have been included
as part of this package.\n
""", 'italic')
        t.insert(END, '[email protected]\n\n', 'blue')
        t.insert(END, '* Goto Field\n', 'bold')
        t.insert(END, '\tinserting one position moves cursor to position\n')
        t.insert(END, "\tinserting two positions, sperated by ':' ")
        t.insert(END, 'highlights', 'highlight')
        t.insert(END, ' selected range\n')
        t.insert(END, '\n')
        t.insert(END, '* Search\n', 'bold')
        t.insert(END, '\tambiguous dna values are\n')
        t.insert(END, """
                A: A
                C: C
                G: G
                T: T
                M: AC
                R: AG
                W: AT
                S: CG
                Y: CT
                K: GT
                V: ACG
                H: ACT
                D: AGT
                B: CGT
                X: GATC
                N: GATC

                """, 'small')
コード例 #30
0
ファイル: receipt.py プロジェクト: edwardsharp/python
class App(object):

  def __init__(self):
    self.window = tk.Tk()
    self.window.attributes("-fullscreen",True)
    self.window.minsize(width=320, height=240)
    self.window.maxsize(width=320, height=240)

    self.buttonFrame = tk.Frame(self.window)

    self.printButton=tk.Button(self.buttonFrame, text='PRINT!', height=2, command=self.printTxt)
    self.printButton.pack(side=tk.LEFT, fill=tk.X, padx=5, pady=5)

    self.loadButton=tk.Button(self.buttonFrame, text='LOAD', height=2, command=self.load)
    self.loadButton.pack(side=tk.LEFT, fill=tk.X, padx=5, pady=5, expand=1)

    self.exitButton=tk.Button(self.buttonFrame, text='EXIT', height=2, command=self.exitWin)
    self.exitButton.pack(side=tk.LEFT, fill=tk.X, padx=5, pady=5, expand=1)

    self.buttonFrame.pack(side=tk.TOP)

    self.filename = '/home/pi/Desktop/fly.txt'

    self.txt = ScrolledText(self.window)
    self.txt.vbar.config(width=18)
    self.txt.pack(expand=True, fill=tk.BOTH)

    self.loadFile()

    self.poll()

  def poll(self):
    if(float(self.txt.vbar.get()[1])==1):
      self.txt.see(1.0) #goto top
    else:
      self.txt.yview(tk.SCROLL,1,tk.UNITS)
    self.window.after(1000, self.poll)

  def load(self):
    self.filename = askopenfilename(initialdir="/home/pi/Desktop", title="SELECT TXT", filetypes=(("txt files","*.txt"),("all files","*.*")) )
    self.loadFile()

  def loadFile(self):
    self.txt.delete(1.0,tk.END)
    fly = open(self.filename,'r')
    self.txt.insert(1.0, fly.read())
    fly.close()

  def printTxt(self):
    call(["lp", self.filename])
    tkMessageBox.showinfo("PRINT", "it's printing!")

  def exitWin(self):
    result = tkMessageBox.askquestion("EXIT?!", "zomg, u sure?", icon='warning')
    if result == 'yes':
      self.window.quit()
コード例 #31
0
    def _getHelp(self):
        win = Tk.Toplevel(self.tks)
        win.title("Help")
        helptext = ScrolledText(win)
        helptext.config(state=Tk.NORMAL)
        helptext.insert('1.0', __help_text__)
        helptext.config(state=Tk.DISABLED)

        helptext.pack()
        Tk.Button(win, text='OK', command=win.destroy).pack()
コード例 #32
0
ファイル: gui.py プロジェクト: binplumage/pocky
class MainApplication():
    def __init__(self, master):

        self.filename = ""
        self.confg = ""
        self.master = master
        #setting color.
        bkc = "floral white"
        fgc = "RosyBrown4"
        bgc = "misty rose"

        self.FontForButton = tkFont.Font(family="Verdana", size=12)
        self.FontForLabel = tkFont.Font(family="Verdana", weight="bold")
        self.frame = tk.Frame(self.master, bg=bkc)
        self.frame.pack()
        self.chose_button = tk.Button(self.frame, text = u"選擇檔案", command = self.open_file, font=self.FontForButton, width = 20, bg=bgc, fg=fgc)
        self.chose_button.pack(padx = 5, pady = 10, side = tk.TOP)
        self.chose_confg_button = tk.Button(self.frame, text = u"選擇設定檔", command = self.get_confg, font=self.FontForButton, width = 20, bg=bgc, fg=fgc)
        self.chose_confg_button.pack(padx = 5, pady = 10, side = tk.TOP)
        self.run_button = tk.Button(self.frame, text = u"執行", command = self.run, font=self.FontForButton, width = 20, bg=bgc, fg=fgc)
        self.run_button.pack(padx = 5, pady = 10, side = tk.TOP)
        self.text = ScrolledText(self.frame)
        self.text.pack()
        self.mdby = tk.Label(self.frame, text="\nPowered By MITLab", font=self.FontForLabel, fg="SkyBlue1", bg=bkc)
        self.mdby.pack(side='bottom')

    def open_file(self):
        self.filename = tkFileDialog.askopenfilename()
        if self.filename :
            setup_env.display_message(u"選擇檔案: " + self.filename)

    def get_confg(self):
        self.confg = tkFileDialog.askopenfilename()
        if self.confg :
            setup_env.display_message(u"選擇設定檔案: " + self.confg)

    def write(self, massage):
        self.text.insert(tk.END, massage)
        self.text.see(tk.END)
        self.text.update_idletasks()#display message real time

    def run(self):
        try:
            if not self.filename or not self.confg:
                raise Exception('請選擇檔案!')
            setup_env.display_message(u"開始執行...")
            setup_env.set_environment(self.confg)
            table = rw_data.read_excel(self.filename, 0)
            rw_data.get_title_col(table)
            cmp_data.filter_data(table)
            cmp_data.cmp_data()
        except Exception as e:
            setup_env.display_message(e.message)
        finally:
            setup_env.clean_envirnoment()
コード例 #33
0
 def add_tab(self, text='new', dirty=True):
     f = ttk.Frame(self.nb)
     # see http://stackoverflow.com/questions/13832720/how-to-attach-a-scrollbar-to-a-text-widget
     t = ScrolledText(f, relief=tk.RAISED, wrap=tk.WORD)
     t.insert(tk.INSERT, text)
     t.pack(fill=tk.BOTH, expand=1)
     t.bind("<KeyRelease>", self.update)
     self.nb.add(f)
     self.tabs.append(t)
     self.nb.select(self.nb.tabs()[-1])
     self.update(dirty=dirty)
コード例 #34
0
ファイル: tkui.py プロジェクト: v-legoff/accertin
class Autotyper:
    """
  Autotyper class, it generates the autotyper window, waits for entering text
  and then calls a function to work with the text.
  """

    def __init__(self, master, sendfunc):
        """
    Initializes the autotyper.
    
    @param master: the main tk window
    @type  master: Tk

    @param sendfunc: the callback function
    @type  sendfunc: function
    """
        self._sendfunc = sendfunc

        self._frame = Toplevel(master)

        # self._frame.geometry("400x300")
        self._frame.title("Lyntin -- Autotyper")

        self._frame.protocol("WM_DELETE_WINDOW", self.cancel)

        if os.name == "posix":
            fontname = "Courier"
        else:
            fontname = "Fixedsys"
        fnt = tkFont.Font(family=fontname, size=12)

        self._txt = ScrolledText(self._frame, fg="white", bg="black", font=fnt, height=20)
        self._txt.pack(side=TOP, fill=BOTH, expand=1)

        self._send_btn = Button(self._frame, text="Send", command=self.send)
        self._send_btn.pack(side=LEFT, fill=X, expand=0)

        self._cancel_btn = Button(self._frame, text="Cancel", command=self.cancel)
        self._cancel_btn.pack(side=RIGHT, fill=X, expand=0)

    def send(self):
        """
    Will be called when the user clicks on the 'Send' button.
    """
        text = fix_unicode(self._txt.get(1.0, END))
        self._sendfunc(text)
        self._frame.destroy()

    def cancel(self):
        """
    Will be called when the user clicks on the 'Cancel' button.
    """
        self._sendfunc(None)
        self._frame.destroy()
コード例 #35
0
def tk_scroll(text, title='Help'):
    win = Tk()

    fnt = tkFont.Font(family="Fixedsys", size=12)
    fnt = tkFont.Font(family="Courier", size=12)

    scroll = ScrolledText(win, fg='white', bg='black', font=fnt, height=20)
    scroll.pack(side=BOTTOM, fill=BOTH, expand=1)
    scroll.insert('end', text)
    Button(win, text='OK', command=win.destroy).pack(side=BOTTOM)
    win.title(title)
    return win
コード例 #36
0
ファイル: libmisc.py プロジェクト: OSadovy/lyntin
def tk_scroll(text, title = 'Help'):
  win = Tk()

  fnt = tkFont.Font(family="Fixedsys", size=12)
  fnt = tkFont.Font(family="Courier", size=12)
  
  scroll = ScrolledText(win, fg='white', bg='black', font=fnt, height=20)
  scroll.pack(side=BOTTOM, fill=BOTH, expand=1)
  scroll.insert('end', text)
  Button(win, text='OK', command=win.destroy).pack(side=BOTTOM)
  win.title(title)
  return win
def onViewMail():
    # view selected message
    msgnum = selectedMsg()
    if not (1 <= msgnum <= len(msgList)):
        showerror('PyMail', 'No message selected')
    else:
        text = msgList[msgnum - 1]  # or put in a TextEditor
        from ScrolledText import ScrolledText
        window = Toplevel()
        window.title('PyMail message viewer #' + str(msgnum))
        browser = ScrolledText(window)
        browser.insert('0.0', text)
        browser.pack(expand=YES, fill=BOTH)
def onViewMail():
    # view selected message
    msgnum = selectedMsg()
    if not (1 <= msgnum <= len(msgList)):
        showerror('PyMail', 'No message selected')
    else:
        text = msgList[msgnum-1]                # or put in a TextEditor
        from ScrolledText import ScrolledText
        window  = Toplevel()
        window.title('PyMail message viewer #' + str(msgnum))
        browser = ScrolledText(window)
        browser.insert('0.0', text)
        browser.pack(expand=YES, fill=BOTH)
コード例 #39
0
def onViewRawMail():
    # view selected message - raw mail text with header lines
    msgnum = selectedMsg()
    if not (1 <= msgnum <= len(msgList)):
        showerror("PyMail", "No message selected")
    else:
        text = msgList[msgnum - 1]  # put in ScrolledText
        from ScrolledText import ScrolledText

        window = Toplevel()
        window.title("PyMail raw message viewer #" + str(msgnum))
        browser = ScrolledText(window)
        browser.insert("0.0", text)
        browser.pack(expand=YES, fill=BOTH)
コード例 #40
0
ファイル: ErrDialog.py プロジェクト: jfmc/logen
class NoAnnDialog(Dialog):
    result = None

    def __init__(self,master=None, Title="No Annotation File Found", Filename="",
                 Msg="The file you have loaded does not have an associated annotation file"):
        self.Title=Title
        self.Msg=Msg
        self.filename = Filename
        
        #self.Short = Short
        
        Dialog.__init__(self,master,title=self.Title)
        
        
    def body(self,unused):
        self.text = ScrolledText(self)
        
        self.text["height"] = "6"
        self.text["width"] = "50"
        
        self.text.pack(side="top",expand="yes",fill="both")
        self.text.insert("1.0", self.Msg)
        self.text["state"] = "disabled"
        self.result = False

    def ok(self, unused=None):
    	self.result = True
        Dialog.ok(self)
        return True
    

    def buttonbox(self):
        box = Frame(self)

        w = Button(box, text="Simple BTA", width=10, command=lambda :self.click("simple"), default=ACTIVE)
        w1 = Button(box, text="Reset File", width=10, command=lambda :self.click("reset"), default=ACTIVE)
        w2 = Button(box, text="Mark Unknown", width=10, command=lambda :self.click("unknown"), default=ACTIVE)        

        w.pack(side=LEFT, padx=5, pady=5)
        w1.pack(side=LEFT, padx=5, pady=5)
        w2.pack(side=LEFT, padx=5, pady=5)

        #self.bind("<Return>", self.ok)


        box.pack()

    def click(self, value):
        self.result = value        
        Dialog.ok(self)
コード例 #41
0
def example():
    import __main__
    from Tkconstants import END

    stext = ScrolledText(bg='white', height=10)
    stext.insert(END, __main__.__doc__)

    f = Font(family="times", size=30, weight="bold")
    stext.tag_config("font", font=f)

    stext.insert(END, "Hello", "font")
    stext.pack(fill=BOTH, side=LEFT, expand=True)
    stext.focus_set()
    stext.mainloop()
コード例 #42
0
class EmailPage(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        case_name = entry.get()
        label = tk.Label(self,text=case_name)
        label.pack(side="top", fill="x", pady=10)
    
        sidebar = Frame(self , width=200 , bg='white' , height=500, relief='sunken' , borderwidth=2)
        sidebar.pack(expand=True , fill='y' , side='left' , anchor='nw')
    
        screen = Frame(self, width=200, bg='white', height=500, relief='sunken', borderwidth=2)
        screen.pack(expand=True, fill='y', side='left', anchor='nw')
    
        self.text = ScrolledText(screen, undo=True)
        self.text['font'] = ('consolas', '12')
        self.text.grid(row=0,column=4)
        self.text.pack(expand=True, fill='both',side=RIGHT)
        
        label = tk.Label(sidebar,text='',width=20,bg="white")
        label.pack()
        button = tk.Button(sidebar, text="Start",command=lambda:self.run_script(),width=20)
        button.pack()

        label = tk.Label(sidebar,text='',width=20,bg="white")
        label.pack()
        button = tk.Button(sidebar, text="Go Back <<",command=lambda:controller.show_frame("PageTwo"),width=20)
        button.pack()


    def run_script(self):
        
        sys.stdout = self
        tkMessageBox.showinfo('FYI', 'Analyzing...Please Wait')
        import final_spam
        final_spam
        self.que()
    def write(self, txt):
        self.text.insert(INSERT, txt)

    def que(self):
        conn=pymysql.connect(host="localhost",user="******",passwd="1234567890",db="poject")
        cursor = conn.cursor()
        rep=self.text.get('1.0', 'end')
        cursor.execute("SELECT @id := (SELECT caseid FROM poject.case ORDER BY caseid DESC LIMIT 1)")
        cursor.execute("UPDATE  poject.case set email_report=%s where caseid=@id", (rep))
        conn.commit()
        conn.close()
        return
コード例 #43
0
ファイル: popuputil.py プロジェクト: qiupq/LearnPython
 def __init__(self, appname, helptext, iconfile=None, showsource=lambda: 0):
     PopupWindow.__init__(self, appname, 'Help', iconfile)
     from ScrolledText import ScrolledText  # a non-modal dialog
     bar = Frame(self)  # pack first=clip last
     bar.pack(side=BOTTOM, fill=X)
     code = Button(bar, bg='beige', text="Source", command=showsource)
     quit = Button(bar, bg='beige', text="Cancel", command=self.destroy)
     code.pack(pady=1, side=LEFT)
     quit.pack(pady=1, side=LEFT)
     text = ScrolledText(self)  # add Text + scrollbar
     text.config(font=self.myfont, width=70)  # too big for showinfo
     text.config(bg='steelblue', fg='white')  # erase on btn or return
     text.insert('0.0', helptext)
     text.pack(expand=YES, fill=BOTH)
     self.bind("<Return>", (lambda event: self.destroy()))
コード例 #44
0
def onViewRawMail():
    # view selected message - raw mail text with header lines
    msgnum = selectedMsg()
    # print(len(msgList))
    if not (1 <= msgnum <= len(msgList)):
        showerror('DFS', 'No message selected')
    else:
        text = client_GUI.client_read("file" +
                                      str(msgnum))  # put in ScrolledText
        from ScrolledText import ScrolledText
        window = Toplevel()
        window.title('DFS raw message viewer #' + str(msgnum))
        browser = ScrolledText(window)
        browser.insert('0.0', text)
        browser.pack(expand=YES, fill=BOTH)
コード例 #45
0
class CopyableMessageWindow(basicWindow):
    """ Creates a modeless (non-modal) message window that allows the user to copy the presented text. """
    def __init__(self, topLevel, message, title, align, buttons, makeModal):
        self.guiRoot = topLevel

        basicWindow.__init__(self,
                             topLevel,
                             title,
                             resizable=True,
                             topMost=False)

        linesInMessage = len(message.splitlines())
        if linesInMessage > 17: height = 22
        else: height = linesInMessage + 5

        self.messageText = ScrolledText(self.mainFrame,
                                        relief='groove',
                                        wrap='word',
                                        height=height)
        self.messageText.insert('1.0', '\n' + message)
        self.messageText.tag_add('All', '1.0', 'end')
        self.messageText.tag_config('All', justify=align)
        self.messageText.pack(fill='both', expand=1)

        # Add the buttons
        self.buttonsFrame = Tk.Frame(self.mainFrame)
        ttk.Button(self.buttonsFrame, text='Close',
                   command=self.close).pack(side='right', padx=5)
        if buttons:
            for button in buttons:
                buttonText, buttonCommand = button
                ttk.Button(self.buttonsFrame,
                           text=buttonText,
                           command=buttonCommand).pack(side='right', padx=5)
        ttk.Button(self.buttonsFrame,
                   text='Copy text to Clipboard',
                   command=self.copyText).pack(side='right', padx=5)
        self.buttonsFrame.pack(pady=3)

        if makeModal:
            self.window.grab_set()
            self.guiRoot.wait_window(self.window)

    # Button functions
    def copyText(self):
        self.guiRoot.clipboard_clear()
        self.guiRoot.clipboard_append(
            self.messageText.get('1.0', 'end').strip())
def showhelp(helptext=helptext, appname='PyMail'):  # show helptext in
    from ScrolledText import ScrolledText  # a non-modal dialog
    new = Toplevel()  # make new popup window
    bar = Frame(new)  # pack first=clip last
    bar.pack(side=BOTTOM, fill=X)
    code = Button(bar, bg='beige', text="Source", command=showsource)
    quit = Button(bar, bg='beige', text="Cancel", command=new.destroy)
    code.pack(pady=1, side=LEFT)
    quit.pack(pady=1, side=LEFT)
    text = ScrolledText(new)  # add Text + scrollbar
    text.config(font='system', width=70)  # too big for showinfo
    text.config(bg='steelblue', fg='white')  # erase on btn or return
    text.insert('0.0', helptext)
    text.pack(expand=YES, fill=BOTH)
    new.title(appname + " Help")
    new.bind("<Return>", (lambda event, new=new: new.destroy()))
class GuiOutput:
    def __init__(self, parent=None):
        self.text = None
        if parent: self.popupnow(parent)         # popup now or on first write
    def popupnow(self, parent=None):             # in parent now, Toplevel later
        if self.text: return
        self.text = ScrolledText(parent or Toplevel())
        self.text.config(font=('courier', 9, 'normal'))
        self.text.pack()
    def write(self, text):
        self.popupnow()
        self.text.insert(END, str(text))
        self.text.see(END)
        self.text.update()
    def writelines(self, lines):                 # lines already have '\n'
        for line in lines: self.write(line)      # or map(self.write, lines)
コード例 #48
0
ファイル: geditor.py プロジェクト: myzsyweb/Casuistry
class Application(Frame):
    def runCode(self):
        import traceback
        reload(main) 
        s = main.Scm()
        #print self.editor.get("1.0", "end-1c")
        code = self.editor.get("1.0", "end-1c")
        try:
            code = s.sh("(begin %s)"%code)
            self.output.delete("1.0", "end-1c")
            self.output.insert("1.0", code)
        except Exception as e:
            code = str(e)
            self.output.delete("1.0", "end-1c")
            self.output.insert("1.0", code)
            traceback.format_exc()
            if ShowDebugInfo:
                tkMessageBox.showwarning("Error", traceback.format_exc())
            #traceback.print_exc()
        self.output.delete("1.0", "end-1c")
        self.output.insert("1.0", code)
    def help(self):
        code = """A Simple Editor For Casuistry Scheme"""
        self.output.delete("1.0", "end-1c")
        self.output.insert("1.0", code)

    def createWidgets(self):
        self.debug = Checkbutton(self,text="debug")
        self.quit = Button(self,text="Quit",command=self.quit)
        self.run = Button(self,text="Run",command= self.runCode)
        self.help = Button(self,text="Help",command=self.help)
        self.editor = ScrolledText(wrap="word")
        self.output = ScrolledText(wrap="word",height=7)
        
        self.debug.pack({"side": "left"})
        self.run.pack({"side": "left"})
        self.help.pack({"side": "left"}) 
        self.quit.pack({"side": "left"})
        
        self.output.pack(side=BOTTOM,expand=TRUE,fill=BOTH)
        self.editor.pack(side=BOTTOM,expand=TRUE,fill=BOTH)

        self.editor.focus_set()
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()
コード例 #49
0
class my_form(Frame):
    """Form"""
    def __init__(self, master=None):
        """create elements of form"""
        Frame.__init__(self, master)
        self.pack()
        #self.createWidgets()

        self.textBox = ScrolledText(self, height=15, width=100)
        self.textBox.pack()
        self.textBox.tag_config("b", foreground="blue")
        self.textBox.tag_config("r", foreground="red")
        # insert the msg from lets_rock will display when finished,
        # that's to late
        if os.getenv('LANG')[0:2] == "de":
            self.textBox.insert(END,
                "Es kann eine Weile dauern, "
                + "vielleicht eine Tasse Kaffee geniessen...")
        else:
            self.textBox.insert(END,
            "Working, this can take a while, enjoy a cup of coffee...\n")
        self.pressButton = Button(self,
                text="ID3 easyTAG Editor", command=self.call_id3_editor)
        # the button will appear when finished
        #self.pressButton.pack()

        # registering callback
        self.listenID = self.after(400, self.lets_rock)
        #self.listenID = self.lets_rock

    def display_logging(self, log_message, text_format):
        """display messages in form, loading periodically """
        if text_format is None:
            self.textBox.insert(END, log_message + "\n")
        else:
            self.textBox.insert(END, log_message + "\n", text_format)

    def call_id3_editor(self):
        self.textBox.insert(END, "Click" + "\n")
        # start subprocess
        try:
            subprocess.Popen(["easytag", ac.app_workin_path],
                stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
        except Exception, e:
            self.display_logging("Error: %s" % str(e), "r")

        return None
コード例 #50
0
class CopyableMsg(basicWindow):
    """ Creates a modeless (non-modal) message window that allows the user to easily copy the given text. 
		If buttons are provided, they should be an iterable of tuples of the form (buttonText, buttonCallback). """
    def __init__(self,
                 root,
                 message='',
                 title='',
                 alignment='center',
                 buttons=None):
        super(CopyableMsg, self).__init__(root,
                                          title,
                                          resizable=True,
                                          topMost=False)
        self.root = root

        if alignment == 'left':
            height = 22  # Expecting a longer, more formal message
        else:
            height = 14

        # Add the main text display of the window
        self.messageText = ScrolledText(self.window,
                                        relief='groove',
                                        wrap='word',
                                        height=height)
        self.messageText.insert('1.0', message)
        self.messageText.tag_add('All', '1.0', 'end')
        self.messageText.tag_config('All', justify=alignment)
        self.messageText.pack(fill='both', expand=1)

        # Add the buttons
        self.buttonsFrame = Tkinter.Frame(self.window)
        ttk.Button(self.buttonsFrame, text='Close',
                   command=self.close).pack(side='right', padx=5)
        if buttons:
            for buttonText, buttonCommand in buttons:
                ttk.Button(self.buttonsFrame,
                           text=buttonText,
                           command=buttonCommand).pack(side='right', padx=5)
        ttk.Button(self.buttonsFrame,
                   text='Copy text to Clipboard',
                   command=self.copyToClipboard).pack(side='right', padx=5)
        self.buttonsFrame.pack(pady=3)

    def copyToClipboard(self):
        self.root.clipboard_clear()
        self.root.clipboard_append(self.messageText.get('1.0', 'end'))
コード例 #51
0
ファイル: sdialogue.py プロジェクト: weikang9009/stars
class aAbout(tkSimpleDialog.Dialog):
    """ The application's about box """
    def __init__(self, master=None):
        tkSimpleDialog.Dialog.__init__(self, master)

    def buttonbox(self):
        # Stolen from tkSimpleDialog.py
        # add standard button box. override if you don't want the
        # standard buttons
        box = Tk.Frame(self)
        w = Tk.Button(box, text="OK", width=10)
        w.pack(side=Tk.RIGHT, padx=5, pady=5)
        self.bind("<Return>", self.ok)
        box.pack(side=Tk.BOTTOM, fill=X)

    def body(self, master):
        self.resizable(0, 0)
        self.catIconImage = Tk.PhotoImage(file=GIFFILE)  # statt file=
        self.catIcon = Tk.Label(master, image=self.catIconImage)
        self.catIcon.pack(side=Tk.TOP)
        label = Tk.Label(master, text=crnotice1)
        label.pack(side=Tk.TOP)
        font = "Helvetica " + TITLEFONTSIZE
        label = Tk.Label(master, font=font, text=crnotice2, justify=Tk.CENTER)
        label.pack(side=Tk.TOP)
        color = 'green'
        font = "Helvetica " + AXISFONTSIZE
        self.infoText = ScrolledText(
            master,
            relief=Tk.FLAT,
            padx=3,
            pady=3,
            background=color,
            #foreground="black",
            wrap='word',
            width=60,
            height=12,
            font=font)
        self.infoText.pack(expand=0, fill=X, side=Tk.BOTTOM)
        self.infoText.delete('0.0', Tk.END)
        self.infoText.insert('0.0', getLicense())
        self.infoText.configure(state=Tk.DISABLED)
        self.title("STARS - About")

    def ok(self):
        print 'ok'
コード例 #52
0
ファイル: calculator.py プロジェクト: qiupq/LearnPython
    def onHist(self):
        # show recent calcs log popup
        from ScrolledText import ScrolledText
        new = Toplevel()  # make new window
        ok = Button(new, text="OK", command=new.destroy)
        ok.pack(pady=1, side=BOTTOM)  # pack first=clip last
        text = ScrolledText(new, bg='beige')  # add Text + scrollbar
        text.insert('0.0', self.eval.getHist())  # get Evaluator text
        text.see(END)  # 3.0: scroll to end
        text.pack(expand=YES, fill=BOTH)

        # new window goes away on ok press or enter key
        new.title("PyCalc History")
        new.bind("<Return>", (lambda event: new.destroy()))
        ok.focus_set()  # make new window modal:
        new.grab_set()  # get keyboard focus, grab app
        new.wait_window()  # don't return till new.destroy
コード例 #53
0
def showhelp(helptext=helptext, appname="PyMail"):  # show helptext in
    from ScrolledText import ScrolledText  # a non-modal dialog

    new = Toplevel()  # make new popup window
    bar = Frame(new)  # pack first=clip last
    bar.pack(side=BOTTOM, fill=X)
    code = Button(bar, bg="beige", text="Source", command=showsource)
    quit = Button(bar, bg="beige", text="Cancel", command=new.destroy)
    code.pack(pady=1, side=LEFT)
    quit.pack(pady=1, side=LEFT)
    text = ScrolledText(new)  # add Text + scrollbar
    text.config(font="system", width=70)  # too big for showinfo
    text.config(bg="steelblue", fg="white")  # erase on btn or return
    text.insert("0.0", helptext)
    text.pack(expand=YES, fill=BOTH)
    new.title(appname + " Help")
    new.bind("<Return>", (lambda event, new=new: new.destroy()))
 def onHist(self):
     # show recent calcs log popup
     # self.infobox('PyCalc History', self.eval.getHist()) 
     from ScrolledText import ScrolledText
     new = Toplevel()                                 # make new window
     ok = Button(new, text="OK", command=new.destroy)
     ok.pack(pady=1, side=BOTTOM)                     # pack first=clip last
     text = ScrolledText(new, bg='beige')             # add Text + scrollbar
     text.insert('0.0', self.eval.getHist())          # get Evaluator text
     text.pack(expand=YES, fill=BOTH)
      
     # new window goes away on ok press or enter key
     new.title("PyCalc History")
     new.bind("<Return>", (lambda event, new=new: new.destroy()))
     ok.focus_set()                      # make new window modal:
     new.grab_set()                      # get keyboard focus, grab app
     new.wait_window()                   # don't return till new.destroy
コード例 #55
0
ファイル: sdialogue.py プロジェクト: cyenglish3/stars
class aAbout(tkSimpleDialog.Dialog):
    """ The application's about box """
    def __init__(self, master=None):
	    tkSimpleDialog.Dialog.__init__(self, master)
 
    def buttonbox(self):
	# Stolen from tkSimpleDialog.py
        # add standard button box. override if you don't want the
        # standard buttons
        box = Tk.Frame(self)
        w = Tk.Button(box, text="OK", width=10)
        w.pack(side=Tk.RIGHT, padx=5, pady=5)
        self.bind("<Return>", self.ok)
        box.pack(side=Tk.BOTTOM,fill=X)

   
    def body(self, master):
        self.resizable(0,0)
        self.catIconImage = Tk.PhotoImage(file=GIFFILE) # statt file=
        self.catIcon = Tk.Label(master, image=self.catIconImage)
        self.catIcon.pack(side=Tk.TOP)
        label = Tk.Label(master, text=crnotice1)
        label.pack(side=Tk.TOP)
        font = "Helvetica "+TITLEFONTSIZE
        label = Tk.Label(master, font=font, text=crnotice2,
                justify=Tk.CENTER)
        label.pack(side=Tk.TOP)
        color = 'green'
        font = "Helvetica "+AXISFONTSIZE
        self.infoText = ScrolledText(master, relief=Tk.FLAT, 
                         padx=3, pady=3,
                         background=color, 
                         #foreground="black",
                         wrap='word',
                         width=60, height=12,
                         font=font)
        self.infoText.pack(expand=0, fill=X, side=Tk.BOTTOM)
        self.infoText.delete('0.0', Tk.END)
        self.infoText.insert('0.0', getLicense())	
        self.infoText.configure(state=Tk.DISABLED)
        self.title("STARS - About")


    def ok(self):
        print 'ok'
コード例 #56
0
ファイル: tail.py プロジェクト: FredHutch/IT
class LogViewer(Frame):
    def __init__(self, parent, filename):
        Frame.__init__(self,parent)
        self.filename = filename 
        self.file = open(filename, 'r')
        self.text = ScrolledText(parent)
        self.text.pack(fill=BOTH)
        data = self.file.read()
        self.size = len(data)
        self.text.insert(END, data)
        self.after(100, self.poll)

    def poll(self):
        if os.path.getsize(self.filename) > self.size:
            data = self.file.read()
            self.size = self.size + len(data)
            self.text.insert(END, data)
        self.after(100,self.poll)
コード例 #57
0
ファイル: tkadmin.py プロジェクト: gregr/uriel
class Terminal(Frame):
	def __init__(self, master=None):
		Frame.__init__(self, master)
		self.pack()
		self.CreateWidgets()
		self.prompt = '>>> '
		configfile = open('adminclientconfig.txt', 'r')
		hostname = configfile.readline().strip()
		port = int(configfile.readline().strip())
		username = configfile.readline().strip()
		password = configfile.readline().strip()
		self.conn = Connection(hostname, port, username, password
						,self.ReceiveMessage
						,lambda: self.ReceiveMessage("connection successful")
						,lambda: self.ReceiveMessage("ERROR!!!!"))
	def destroy(self):
		self.conn.Shutdown()
		Frame.destroy(self)
	def CreateWidgets(self):
		self.text = ScrolledText(self, state=DISABLED, height=30)
		self.text["fg"] = "white"
		self.text["bg"] = "black"
		self.text.pack()
		self.entry = Entry(self)
		self.entry["fg"] = "white"
		self.entry["bg"] = "black"
		self.entry.pack(fill=X,pady=0)
		self.entry.bind("<Key-Return>", self.SendMessage)
#		self.entry.bind("<Key-Tab>", lambda _: self.entry.insert(INSERT, "\t"))
	def SendMessage(self, event):
		data = self.entry.get()
		self.entry.delete(0, END)
		self.conn.OnCommand(data, self.OnResult)
		self.ReceiveMessage(self.prompt + data)	# echo
	def ReceiveMessage(self, data):
		self.text.config(state=NORMAL)
		self.text.insert(END, data+"\n")
		self.text.config(state=DISABLED)
		self.text.yview_pickplace('end')
	def OnResult(self, more):
		if more:
			self.prompt = '... '
		else:
			self.prompt = '>>> '
コード例 #58
0
ファイル: terminal_writer.py プロジェクト: markyoder/misc
class Outputter_tk(tk.Tk):
	'''
	# outputter class that uses a Text() object. The text object is mutable, you can  you can cut and paste from the box, which is nice, but you
	# can also inadvertently delete text... which can be bad. as noted below, configure(state='DISABLED') can be used to disable editing,
	# but it also shutd down writing (insert() ), so it will be necessary to toggle this on/off as needed if we want a 'safe' text box.
	'''
	# this is mostly from:
	# http://stackoverflow.com/questions/24707308/get-command-window-output-to-display-in-widget-with-tkinter
	def __init__(self, master=None, x_size=512, y_size=512, title=None):
		# don't know what we're doing with this yet...
		tk.Tk.__init__(self,master)
		self.parent=master
		if title!=None: self.wm_title(str(title))
		self.geometry('%sx%s' % (x_size, y_size))
		#
		#self.grid()
		self.createWidgets()
		#
		#self.display.insert(tk.INSERT, "initial text")
	
	def write(self, input_str=''):
		self.text_var.set(input_str)
		self.display.insert(tk.END, self.text_var.get())
	#
	def writeln(self, input_str=''):	
		self.write(input_str + '\n')
	
	def createWidgets(self):
		#self.quitButton = tk.Button(self, text='Quit',command=self.quit)
		#self.quitButton.grid()
		
		#self.display = tk.Text(master=self, bg='yellow', fg='blue')
		self.display = ScrolledText(master=self, bg='yellow', fg='blue')
		self.display.pack(anchor="w", fill=tk.BOTH, expand=1)
		#
		self.text_var = tk.StringVar()
		#self.entry=tk.Entry(self, textvariable=self.text_var, bg='cyan')		# this is an input type text-box (i'm guessing a 1-line text).
																				# based on the sample source code, input text would go here, then
																				# you'd click an "add" button and it would append the big text box.
		#self.entry.pack(anchor='w')
		#
		self.btn_quit = tk.Button(self, text='Close', command=self.destroy)
		self.btn_quit.pack(anchor='w')
コード例 #59
0
class App(object):

    def __init__(self):
        self.root = tki.Tk()
        self.root.title("Loadshedding Schedule Parser")
        tki.Label(text='Copy Schedules from a table and paste it here:').pack()
        self.txt = ScrolledText(self.root, width="50" ,undo=True)
        self.txt['font'] = ('consolas', '12')
        self.txt.pack(expand=True, fill='both')


	def onok():

          dirname = tdog.askdirectory(parent=self.root,initialdir="/",title='Please select a directory')
          print dirname
          schFunc.parse(self.txt.get("1.0","end"),dirname)
          tbox.showinfo("Done","Schedules have been parsed and converted to INI files")


	tki.Button(self.root, text='Parse Schedules', command=onok).pack()