def __init__(self): root = self.root = Tk() root.wm_title('xcons') # Link Tk into twisted main loop tksupport.install(root) # Create menu bar mbar = Frame(root) mbar.pack(side=TOP, fill=X) if mbar: mb_console = Menubutton(mbar, text='Console', underline=0) if mb_console: menu = mb_console['menu'] = Menu(mb_console, tearoff=0) # menu.add_command(label='Connect...', underline=0) menu.add_command(label='Exit', underline=1, command=root.quit) mb_console.pack(side=LEFT) status = self.status = Label(root) status.pack(side=BOTTOM, anchor=W) # Create text area #xsc = Scrollbar(root, orient=HORIZONTAL) ysc = Scrollbar(root) text = self.text = Text(root, font='jet-small-fixed', yscrollcommand=ysc.set) ysc.config(command=text.yview) ysc.pack(side=RIGHT, fill=Y) text.pack(side=TOP, fill=BOTH) text.bind('<KeyPress>', self.keypress)
def init_gui(context, web_server_running): from twisted.internet import tksupport import tkinter as tk root = tk.Tk() root.resizable(False, False) root.title("") root.geometry("250x438") background_filenames = { None: "gui-background-green.gif", True: "gui-background-green-success.gif", False: "gui-background-green-failure.gif" } background_filename = pkg_resources.resource_filename( "singtclient", background_filenames[web_server_running] ) background_image = tk.PhotoImage( file = background_filename ) # A reference to the image must be kept, or we see only white context["gui_background_image"] = background_image background_label = tk.Label(root, image=background_image) background_label.place(x=0, y=0, relwidth=1, relheight=1) tksupport.install(root) def window_closed(): log.info("The user closed the GUI window") reactor = context["reactor"] reactor.stop() root.protocol("WM_DELETE_WINDOW", window_closed) root.createcommand("::tk::mac::Quit", window_closed)
def __init__(self): # initial parameters self.feature_queue = [] self.root = Tk() self.gui = GUI.GUI(self.feature_queue, self.root) self.gui.recordMaster(self) self.gui.MODE = self.MODE self.log = loginfo.log(self.gui) self.log.info('GUI has been initialized.') self.gui.setLog(self.log) # setup connection with APP tksupport.install(self.root) self.comm = Communicate.communication() self.comm.setLog(self.log) self.listenBegin() self.region = Region.region(position=[-1.0, 1.0, -1.0], log=self.log) self.camera = Camera.camera(angle=[0.0, 0.0]) # initialize region center and camera center # thread control center self.threadStart() self.log.info('Three Mode could be started!') self.log.info('Current Mode is ' + self.MODE + ' Mode.') self.log.info('Please INIT the coordinate system!') self.periodicCall() reactor.run()
def run(): import sys opt = Options() opt.parseOptions(sys.argv[1:]) delay = int(opt['delay']) if opt['proxy']: host = urlparse.urlparse(opt['proxy'])[1] if ':' in host: host, port = host.split(':', 1) port = int(port) else: port = 80 makeChecker = lambda url, notified: monitor.ProxyChangeChecker( host, port, notified, url, delay) else: makeChecker = lambda url, notified: monitor.ChangeChecker( notified, url, delay) from twisted.internet import reactor, tksupport root = Tk.Tk() root.protocol("WM_DELETE_WINDOW", reactor.stop) root.title("Web Monitor") tksupport.install(root) frame = webmonFrame(root, makeChecker, opt.urls) frame.pack() reactor.run()
def main(): """Stand alone client launcher""" # This used to be the main way of launching a remote client # It is now left here only for reference, since Crujisim.py deals # with that using classes from this module. # It would not work now anyway unless executed from the main directory root = Tk() root.withdraw() conf=CrujiConfig() def failed_connection(p): reactor.callWhenRunning(ask_ip) def connectionLost(): try: reactor.stop() except: pass def ask_ip(): try: (ip,port)=ConnectDialog(root,conf).result print ip,port except: reactor.stop() return print "Connecting "+ip+", port "+str(port) RemoteClient().connect(ip,port,ATC, connectionLost).addErrback(failed_connection) reactor.callWhenRunning(ask_ip) tksupport.install(root) reactor.run()
def optionView(self): tksupport.install(self.top) self.top.title('Chat') self.top.geometry( '700x680' ) def callback(): self.stop() self.top.protocol("WM_DELETE_WINDOW", callback) optionView = Frame(self.top) optionView.pack() MyButton = partial(Button, optionView, text='Host a server', command=self.serverView) chooseServer = MyButton() chooseServer.pack() chooseClient = MyButton(text='Connect to a server', command=self.clientView) chooseClient.pack() quitButton = Button(optionView, text='QUIT',command=self.stop) quitButton.pack() self.pages['optionView'] = optionView self.current = 'optionView' reactor.run()
def run(): import sys opt = Options() opt.parseOptions(sys.argv[1:]) delay = int(opt["delay"]) if opt["proxy"]: host = urlparse.urlparse(opt["proxy"])[1] if ":" in host: host, port = host.split(":", 1) port = int(port) else: port = 80 makeChecker = lambda url, notified: monitor.ProxyChangeChecker(host, port, notified, url, delay) else: makeChecker = lambda url, notified: monitor.ChangeChecker(notified, url, delay) from twisted.internet import reactor, tksupport root = Tk.Tk() root.protocol("WM_DELETE_WINDOW", reactor.stop) root.title("Web Monitor") tksupport.install(root) frame = webmonFrame(root, makeChecker, opt.urls) frame.pack() reactor.run()
def main(): dd = DataDecoder() level = LevelFilter() fil = LowPassFilter() serv = UdpServer() fig = plt.figure() dd.on_data.add(fil) fil.on_data.add(level) rows = 3 cols = 1 i = 1 for f in ('x', 'y', 'z'): ax = Axis(fig, [rows, cols, i], dt=1, maxt=100) dd.on_data.add(ax) line = PlotLine(f, color='b') dd.on_data.add(line) ax.add_line(line) linef = PlotLine(f, color='r') fil.on_data.add(linef) ax.add_line(linef) linef = PlotLine(f, color='g') level.on_data.add(linef) ax.add_line(linef) i = i + 1 pass dd_saver = DataSaver('dd') dd.on_data.add(dd_saver) fil_saver = DataSaver('fil') fil.on_data.add(fil_saver) lev_saver = DataSaver('lev') level.on_data.add(lev_saver) serv.on_read.add(dd) plt.ion() plt.plot() plt.draw() tk_win = fig.canvas._master tksupport.install(tk_win) def close_ev(): while True: print 'bye' fig.canvas.mpl_connect('close_event', close_ev) reactor.run() pass
def main(): root = Tk() root.title('BSE Client') root.geometry("600x670") root.pack_propagate(0) ui = UI(root) tksupport.install(root) reactor.run()
def initializeGUI(self): #set up the main window root = Tk() root.title("Encrypted P2P Chat GUI") root.protocol('WM_DELETE_WINDOW', self.closeProgram) mainFrame = Frame(root) mainFrame.pack() self.ConnectionsList.append(Listbox(mainFrame, selectmode=SINGLE)) self.ConnectionsList.append(Listbox(mainFrame, selectmode=SINGLE)) self.ConnectionsList[0].grid(row=0, column=0) self.ConnectionsList[1].grid(row=0, column=1) self.ConnectionsList[0].bind("<<ListboxSelect>>", lambda e:self.syncListSelections(e, listIndex=0)) self.ConnectionsList[1].bind("<<ListboxSelect>>", lambda e:self.syncListSelections(e, listIndex=1)) #set up chat window with scroll bar chatTextFrame = Frame(root) scrollbar = Scrollbar(chatTextFrame) scrollbar.pack(side=RIGHT, fill=Y) self.chatWindow = Text(chatTextFrame, height=8, state=DISABLED) self.chatWindow.pack(side=LEFT, expand=YES, fill=BOTH) scrollbar.config(command=self.chatWindow.yview) self.chatWindow.config(yscrollcommand=scrollbar.set) chatTextFrame.pack(expand=YES, fill=BOTH) #set up user text field for input chatEntryFrame = Frame(root) scrollbar2 = Scrollbar(chatEntryFrame) scrollbar2.pack(side=RIGHT, fill=Y) self.textEntry = Text(chatEntryFrame, height=2) self.textEntry.pack(side=LEFT, expand=YES, fill=BOTH) scrollbar2.config(command=self.textEntry.yview) chatEntryFrame.pack(expand=YES, fill=BOTH) #Bind key events to method calls self.textEntry.bind("<Key>", self.sendChatMessage) self.textEntry.bind("<KeyRelease>", self.clearText) #set up buttons and their method calls refreshButton = Button(root, text="Refresh List", command=self.refreshAvailIP) refreshButton.pack(side=LEFT) exitButton = Button(root, text="Exit Program", command=self.closeProgram) exitButton.pack(side=RIGHT) tksupport.install(root)
def __init__(self): self.root = tk.Tk() self.cnt = 0 self.running = None self.root.protocol('WM_DELETE_WINDOW', self.exit) tksupport.install(self.root) self.tx_loop = task.LoopingCall(self.send_message) self.main_window() # self.root.mainloop() reactor.run()
def __init__(self, ip="localhost"): self.window = Tk() self.canvas = Canvas(self.window, {"height": 700, "width": 1200}) self.canvas.grid(column=0, row=0, sticky=(N, W)) self.game_board = None point = TCP4ClientEndpoint(reactor, ip, 1079) d = point.connect(ObserverProtocolFactory(self.update_board)) tksupport.install(self.window) reactor.run()
def __init__(self, parent): from Tkinter import Tk, Label, Button self.parent = parent self.win = Tk(className='moving') self.win.overrideredirect(1) self.win.tkraise() self.label = Label(self.win, text=' '*25, font='fixed') self.label.pack(padx=20, pady=10) self.button = Button(self.win, text='OK', command=self.parent.hide) self.button.pack(pady=5) tksupport.install(self.win)
def run(): global button global osc_sender osc_sender = UDPSenderApplication(OSC_SEND_PORT, OSC_SEND_HOST) root = Tkinter.Tk() root.wm_title("Color picker osc.udp://%s:%s" % (OSC_SEND_HOST, OSC_SEND_PORT)) button = Tkinter.Button(root, text='Set Background Color', command=set_color) button.config(height=3, font=('times', 20, 'bold')) button.pack(expand=Tkinter.YES, fill=Tkinter.BOTH) tksupport.install(root) reactor.run()
def _start_root(self): if os.name == "nt": button_foreground = "#104639" lookup_button_padding = 10 else: button_foreground = "#FFFFFF" lookup_button_padding = 11 root = tk.Tk() root.resizable(0, 0) root.wm_title("LBRY") tksupport.install(root) if os.name == "nt": root.iconbitmap(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "lbrynet", "lbrynet_downloader_gui", "lbry-dark-icon.ico")) else: root.wm_iconbitmap("@" + os.path.join(os.path.dirname(__file__), "lbry-dark-icon.xbm")) root.button_font = tkFont.Font(size=9) ttk.Style().configure(".", background="#FFFFFF") ttk.Style().configure("LBRY.TButton", background="#104639", foreground=button_foreground, borderwidth=1, relief="solid", font=root.button_font) ttk.Style().map("LBRY.TButton", background=[('pressed', "#104639"), ('active', "#104639")]) #ttk.Style().configure("LBRY.TButton.border", background="#808080") ttk.Style().configure("Lookup.LBRY.TButton", padding=lookup_button_padding) ttk.Style().configure("Stop.TButton", padding=1, background="#FFFFFF", relief="flat", borderwidth=0) ttk.Style().configure("TEntry", padding=11) ttk.Style().configure("Float.TEntry", padding=2) #ttk.Style().configure("A.TFrame", background="red") #ttk.Style().configure("B.TFrame", background="green") #ttk.Style().configure("B2.TFrame", background="#80FF80") #ttk.Style().configure("C.TFrame", background="orange") #ttk.Style().configure("D.TFrame", background="blue") #ttk.Style().configure("E.TFrame", background="yellow") #ttk.Style().configure("F.TFrame", background="#808080") #ttk.Style().configure("G.TFrame", background="#FF80FF") #ttk.Style().configure("H.TFrame", background="#0080FF") #ttk.Style().configure("LBRY.TProgressbar", background="#104639", orient="horizontal", thickness=5) #ttk.Style().configure("LBRY.TProgressbar") #ttk.Style().layout("Horizontal.LBRY.TProgressbar", ttk.Style().layout("Horizontal.TProgressbar")) root.configure(background="#FFFFFF") root.protocol("WM_DELETE_WINDOW", self.stop) self.master = root
def __init__(self): self.window = Tk() self.canvas = Canvas(self.window, { "height": 700, "width": 1450 }) self.canvas.grid(column = 0, row = 0, sticky=(N, W)) self.game_board = None self.actions = None self.simulator_screen = None point = TCP4ClientEndpoint(reactor, "localhost", 1079) d = point.connect(PlayerProtocolFactory(self.update_game)) d.addCallback(self.got_protocol) tksupport.install(self.window) reactor.run()
def showOpenDialog(self, sender): root = Tk() root.withdraw() tksupport.install(root) filename = askopenfilename( defaultextension='.trosrepl', filetypes=[ ('Trosnoth replay', '*.trosrepl'), ], initialdir=getPath(user, replayDir), title='Select replay', ) if filename: self.onReplay.execute(filename)
def setup_window(title = "Turtles"): #setup canvas and make it play nicely with Twisted root = Tkinter.Tk() canvas = Tkinter.Canvas(root,width=WINDOW_WIDTH,height=WINDOW_HEIGHT) canvas.pack(side = Tkinter.LEFT) tksupport.install(root) root.title(title) draw_headings(canvas) root.protocol('WM_DELETE_WINDOW', reactor.stop) return canvas
def __init__(self, p2pObject, dbConnection): self.p2p = p2pObject #self.tracker = trackerclient self.db_conn = dbConnection root = Tk() # This fixes the reactor error on closing root window with the 'X' button from twisted.internet import reactor root.protocol("WM_DELETE_WINDOW", reactor.stop) self.gui = UIInterface(root, self) self.gui.master.title('Independed chat') tksupport.install(root) self.chatinfoqueue = queue.Queue()
def main(): root = Tk() # Install the Reactor support tksupport.install(root) # at this point build Tk app as usual using the root object, # and start the program with "reactor.run()", and stop it # with "reactor.stop()". app = App(root) root.mainloop() root.destroy() # optional; see description below
def __init__(self): root = Tix.Tk() root.withdraw() tksupport.install(root) self.tkroot = root gladefile = GLADE_FILE self.windowname = "splash" splash = self.splash = gtk.glade.XML(gladefile, "Splash") splash.signal_autoconnect(self) gui = self.gui = gtk.glade.XML(gladefile, "MainWindow") gui.signal_autoconnect(self) # Automatically make every widget in the window an attribute of this class for w in gui.get_widget_prefix(''): name = w.get_name() # make sure we don't clobber existing attributes try: assert not hasattr(self, name) except: logging.error("Failed with attr " + name) setattr(self, name, w) reactor.GtkMainWindow = self.MainWindow # This is a very dirty trick popup = self.popup = gtk.glade.XML(gladefile, "MainPopup") popup.signal_autoconnect(self) self.MainPopup = popup.get_widget('MainPopup') # Place the joke lines = open(JOKES, 'rt').readlines() try: j = random.choice(lines) except: j = '' joke = "" for l in j.split("|"): joke += l + "\n" joke = joke[:-1] splash.get_widget('jokelabel').set_text(utf8conv(joke)) splash_window = splash.get_widget("Splash") splash_window.set_position(gtk.WIN_POS_CENTER) splash_window.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH)) splash.get_widget("progressbar").set_text( "Obteniendo lista de ejercicios") self.load() self.check_backup()
def run(): global menu, options, frame args = sys.argv[1:] if "-l" in args: # cvs is an idiot i = args.index("-l") args = args[i : i + 2] + args del args[i + 2 : i + 4] for arg in args[:]: try: i = args.index(arg) if arg[:2] == "-o" and args[i + 1][0] != "-": args[i : i + 2] = [] # suck on it scp except ValueError: pass root = Tkinter.Tk() root.withdraw() top = Tkinter.Toplevel() menu = TkConchMenu(top) menu.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1) options = GeneralOptions() try: options.parseOptions(args) except usage.UsageError as u: print("ERROR: %s" % u) options.opt_help() sys.exit(1) for k, v in options.items(): if v and hasattr(menu, k): getattr(menu, k).insert(Tkinter.END, v) for (p, (rh, rp)) in options.localForwards: menu.forwards.insert(Tkinter.END, "L:%s:%s:%s" % (p, rh, rp)) options.localForwards = [] for (p, (rh, rp)) in options.remoteForwards: menu.forwards.insert(Tkinter.END, "R:%s:%s:%s" % (p, rh, rp)) options.remoteForwards = [] frame = tkvt100.VT100Frame(root, callback=None) root.geometry( "%dx%d" % (tkvt100.fontWidth * frame.width + 3, tkvt100.fontHeight * frame.height + 3) ) frame.pack(side=Tkinter.TOP) tksupport.install(root) root.withdraw() if (options["host"] and options["user"]) or "@" in options["host"]: menu.doConnect() else: top.mainloop() reactor.run() sys.exit(exitStatus)
def show_button(self): global active_buttons global root if not root: root = Tkinter.Tk() root.protocol("WM_DELETE_WINDOW", close_callback) if active_buttons is 0: tksupport.install(root) self.button = Tkinter.Button(root, text=self.text, command=self.tkinter_button_callback) self.button.pack() active_buttons += 1
def main(): from twisted.python import log log.startLogging(sys.stdout) symbol = Symbol.X if len(sys.argv) > 1: arg = sys.argv[1].strip().lower() symbol = Symbol.X if arg == 'x' else Symbol.O log.msg('The symbol for the human player is ', symbol) app = App(None, symbol) app.eval('tk::PlaceWindow %s center' % app.winfo_pathname(app.winfo_id())) tksupport.install(app) reactor.run()
def run(): global menu, options, frame args = sys.argv[1:] if '-l' in args: # cvs is an idiot i = args.index('-l') args = args[i:i+2]+args del args[i+2:i+4] for arg in args[:]: try: i = args.index(arg) if arg[:2] == '-o' and args[i+1][0]!='-': args[i:i+2] = [] # suck on it scp except ValueError: pass root = Tkinter.Tk() root.withdraw() top = Tkinter.Toplevel() menu = TkConchMenu(top) menu.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1) options = GeneralOptions() try: options.parseOptions(args) except usage.UsageError as u: print('ERROR: %s' % u) options.opt_help() sys.exit(1) for k,v in options.items(): if v and hasattr(menu, k): getattr(menu,k).insert(Tkinter.END, v) for (p, (rh, rp)) in options.localForwards: menu.forwards.insert(Tkinter.END, 'L:%s:%s:%s' % (p, rh, rp)) options.localForwards = [] for (p, (rh, rp)) in options.remoteForwards: menu.forwards.insert(Tkinter.END, 'R:%s:%s:%s' % (p, rh, rp)) options.remoteForwards = [] frame = tkvt100.VT100Frame(root, callback=None) root.geometry('%dx%d'%(tkvt100.fontWidth*frame.width+3, tkvt100.fontHeight*frame.height+3)) frame.pack(side = Tkinter.TOP) tksupport.install(root) root.withdraw() if (options['host'] and options['user']) or '@' in options['host']: menu.doConnect() else: top.mainloop() reactor.run() sys.exit(exitStatus)
def make_client(): root = tk.Tk() root.title('Tkwidgets application') login_window = LoginWindow(root) factory = ClientFactory(root, on_connect=functools.partial( setattr, login_window, 'handle'), on_login=login_window.lock, on_logout=login_window.unlock) reactor.connectTCP('localhost', STANDARD_PORT, factory) tksupport.install(root) reactor.run()
def make_client(): root = tk.Tk() root.title('Tkwidgets application') login_window = LoginWindow(root) factory = ClientFactory( root, on_connect=functools.partial(setattr, login_window, 'handle'), on_login=login_window.lock, on_logout=login_window.unlock ) reactor.connectTCP('localhost', STANDARD_PORT, factory) tksupport.install(root) reactor.run()
def main(application): import sys from shtoom.ui.util import maybeInstallDBus maybeInstallDBus() from twisted.internet import reactor from twisted.internet import tksupport from shtoom.ui.tkui import ShtoomMainWindow UI = ShtoomMainWindow() tksupport.install(UI.getMain()) UI.connectApplication(application) from shtoom import log if application.getPref('stdout'): import sys log.startLogging(sys.stdout, setStdout=False) else: log.startLogging(UI.getLogger(), setStdout=False) return UI
def main(): logging.basicConfig( filename="client.log", level=logging.INFO, format="%(asctime)s - %(name)s - %(thread)d - %(levelname)s - %(message)s", datefmt="%m/%d/%Y %I:%M:%S %p", ) root = Tk() root.protocol("WM_DELETE_WINDOW", lambda: on_closing(root, reactor)) # Install the Reactor support tksupport.install(root) # set rez root.geometry(rez) root.wm_title(title) # create app obj app = Application(reactor, master=root) # main loop from reactor.run()
def run(): taps = mktap.loadPlugins() r = Tkinter.Tk() r.withdraw() keyList = taps.keys() keyList.sort() config = TkMkAppFrame(r, None) menu = TkAppMenu( r, config.createApplication, lambda i, d = taps, c = config: c.reset(d[i]), keyList ) config.pack() r['menu'] = menu r.title('Twisted Application Maker ' + version) r.deiconify() tksupport.install(r) reactor.run()
def showLoadReplayFileDialog(self): root = Tk() root.withdraw() tksupport.install(root) filename = askopenfilename( defaultextension='.trosrepl', filetypes=[ ('Trosnoth replay', '*.trosrepl'), ], initialdir=getPath(user, replayDir), title='Select replay', ) if filename: try: self.app.connector.openReplay(filename) except ReplayFileError: self.showReplayFileError() except: log.exception('Error while opening replay file') self.showReplayFileError()
def __init__(self): self.window = Tk() self.window["bg"] = self.BACKGROUND self.window.title(APP_NAME) self.window.minsize(700, 550) tksupport.install(self.window) self.window.protocol("WM_DELETE_WINDOW", self.application_quit) self.createMenu() selectionGet = self.window.selection_get self.client = Client(self, selectionGet) self.client.pack() self.factory = pb.PBClientFactory() self.window.wait_visibility() self.logindialog = LoginDialog(self.window, self.loginSuccess, self.application_quit, REMOTE_SERVER, self.PORTNO, self.factory, self.client.cc) reactor.callWhenRunning(self.logindialog.run) reactor.run()
def __init__(self, controller=None): self.root = Tk() tksupport.install(self.root) # h = self.root.winfo_screenheight() w = self.root.winfo_screenwidth() self.screenSize = (w, w / 2) # the width of the picture for this game is twice as wide as its height # d = MyDialog(self.root) # print "result", d.size self.canvas = Canvas(self.root, width=self.screenSize[0], height=self.screenSize[1]) self.controller = controller topFrame = Frame(self.root) topFrame.pack(side=TOP) self.question = StringVar() self.answer = StringVar() self.timeText = StringVar() self.scoreText = StringVar() self.scoresText = StringVar() self.nextRound = StringVar() self.nameInput = Entry(topFrame) self.nameInput.grid(row=0, column=1, sticky=W) Label(topFrame, text="Enter your name here: ").grid(row=0, column=0, sticky=W) Label(topFrame, textvariable=self.question).grid(row=1, column=2, sticky=W) Label(topFrame, textvariable=self.answer).grid(row=1, column=3, sticky=W) Label(topFrame, textvariable=self.scoreText).grid(row=0, column=3, sticky=E) # Label(topFrame, textvariable=self.timeText).grid(row=2, column=1, sticky=W) self.progressBar = ProgressBar(topFrame, value=0, max=5, width=400) self.progressBar.grid(row=0, column=2, sticky=W) # self.nextRoundBar = ProgressBar(topFrame, value=5000, max=5000, width=400) # self.nextRoundBar.grid(row=1, column=2, sticky=W) Label(topFrame, textvariable=self.nextRound).grid(row=0, column=3, sticky=W) # Button(topFrame, text="Get Question", command=self.controller.getQuestion).grid(row=2, column=1, sticky=W) # Button(topFrame, text="New Game", command=self.controller.restartGame).grid(row=2, column=3, sticky=W) Button(topFrame, text="Quit", command=self.quit).grid(row=0, column=4, sticky=W) Button(topFrame, text="Restart", command=self.restart).grid(row=0, column=5, sticky=W) large = 1600 self.imageId = None # self.makeImage(mapFile, None) self.canvas.bind("<Button-1>", self.controller.mouseEvent) self.canvas.pack(side=BOTTOM) self.lines = [] self.map = None
def run(): taps = mktap.loadPlugins() r = Tkinter.Tk() r.withdraw() keyList = taps.keys() keyList.sort() config = TkMkAppFrame(r, None) menu = TkAppMenu(r, config.createApplication, lambda i, d=taps, c=config: c.reset(d[i]), keyList) config.pack() r['menu'] = menu r.title('Twisted Application Maker ' + version) r.deiconify() tksupport.install(r) reactor.run()
def doItTkinterly(opt): root = Tkinter.Tk() root.withdraw() root.title('One Moment.') root.protocol('WM_DELETE_WINDOW', reactor.stop) tksupport.install(root) prog = ProgressBar(root, value=0, labelColor="black", width=200) prog.pack() # callback immediately d = defer.succeed(root).addErrback(log.err) def deiconify(root): root.deiconify() return root d.addCallback(deiconify) if opt['zipfile']: uz = Progressor('Unpacking documentation...') max = zipstream.countZipFileChunks(opt['zipfile'], 4096) uz.setBar(prog, max) uz.setIterator( zipstream.unzipIterChunky(opt['zipfile'], opt['ziptargetdir'])) d.addCallback(uz.processAll) if opt['compiledir']: comp = Progressor('Compiling to pyc...') comp.setBar(prog, countPysRecursive(opt['compiledir'])) comp.setIterator(compiler(opt['compiledir'])) d.addCallback(comp.processAll) def stop(ignore): reactor.stop() root.destroy() d.addCallback(stop) reactor.run()
def doItTkinterly(opt): root=Tkinter.Tk() root.withdraw() root.title('One Moment.') root.protocol('WM_DELETE_WINDOW', reactor.stop) tksupport.install(root) prog=ProgressBar(root, value=0, labelColor="black", width=200) prog.pack() # callback immediately d=defer.succeed(root).addErrback(log.err) def deiconify(root): root.deiconify() return root d.addCallback(deiconify) if opt['zipfile']: uz=Progressor('Unpacking documentation...') max=zipstream.countZipFileChunks(opt['zipfile'], 4096) uz.setBar(prog, max) uz.setIterator(zipstream.unzipIterChunky(opt['zipfile'], opt['ziptargetdir'])) d.addCallback(uz.processAll) if opt['compiledir']: comp=Progressor('Compiling to pyc...') comp.setBar(prog, countPysRecursive(opt['compiledir'])) comp.setIterator(compiler(opt['compiledir'])) d.addCallback(comp.processAll) def stop(ignore): reactor.stop() root.destroy() d.addCallback(stop) reactor.run()
def run(): r = Tkinter.Tk() r.withdraw() tksupport.install(r) filename = tkFileDialog.askopenfilename( parent=r, title="Select Twisted APplication File", filetypes=FILE_TYPES ) working = askdirectory( parent=r, title="Select Working Directory" ) os.chdir(working) pickOptions(r, filename) from twisted.copyright import version r.title('Twisted Daemon Launcher ' + version) r.deiconify() reactor.run()
def __init__(self): self.root = Tk() self.root.title("TP2PClient") tksupport.install(self.root) #VARS self.user_name = StringVar() self.user_name.set("Username") self.root_directory = StringVar() self.root_directory.set("Root Directory") self.server_ip = StringVar() self.server_ip.set("Server IP") self.search_text = StringVar() self.search_text.set("Search") self.status_label = StringVar() self.status_label.set("Status") self.search_results = StringVar() self.descriptors = StringVar()
def initialGUI(self): # Initialing tkinter creates the root window and the tkinter interpreter root = Tk() # This installs the tkinter object into the twisted event loop. It will no longer hijack the main loop. tksupport.install(root) # Set the size of the tkinter window, we only need a small work space for the initial UI root.geometry("300x300+200+200") root.title('Initial Setup') root.geometry('{}x{}'.format(460, 350)) leftFrame = Frame(root) leftFrame.pack(side="left", expand=True, fill="both") # Create a frame to be added to the window, this will be the right hand side of the UI rightFrame = Frame(root) rightFrame.pack(side="right", expand=True, fill="both") # Create a frame to be added to the window, this will be the left hand side of the UI leftFrame = Frame(root) leftFrame.pack(side="left", expand=True, fill="both") # This form is used for joining an exisiting network # Begin populating left frame with Labels and Entrys to take form data, uses tkinter grid method for positioning Label(leftFrame, text="Bootstrapping IP").grid(row=0, column=2, sticky=W) initialIP = Entry(leftFrame, width=19) initialIP.grid(row=1, column=2, sticky=W) Label(leftFrame, text="Boostrapping Port").grid(row=2, column=2, sticky=W) initialPort = Entry(leftFrame, width=19) initialPort.grid(row=3, column=2, sticky=W) Label(leftFrame, text="Your IP").grid(row=4, column=2, sticky=W) yourIP = Entry(leftFrame, width=19) yourIP.grid(row=5, column=2, sticky=W) Label(leftFrame, text="Your Port").grid(row=6, column=2, sticky=W) yourPort = Entry(leftFrame, width=19) yourPort.grid(row=7, column=2, sticky=W) Label(leftFrame, text="Username").grid(row=8, column=2, sticky=W) userName = Entry(leftFrame, width=19) userName.grid(row=9, column=2, sticky=W) # This form is used for starting a new network # Begin populating left frame with Labels and Entrys to take form data, uses tkinter grid method for positioning Label(rightFrame, text="Username").grid(row=8, column=2, sticky=W) username = Entry(rightFrame, width=19) username.grid(row=9, column=2, sticky=W) Label(rightFrame, text="Your IP").grid(row=10, column=2, sticky=W) yourip = Entry(rightFrame, width=19) yourip.grid(row=11, column=2, sticky=W) Label(rightFrame, text="Your Port").grid(row=12, column=2, sticky=W) yourport = Entry(rightFrame, width=19) yourport.grid(row=13, column=2, sticky=W) Button(leftFrame, text='Connect to existing', command=lambda arg1=initialIP, arg2=initialPort, arg3=yourIP, arg4=yourPort, arg5=userName: self.connectToExistingNetwork( arg1, arg2, arg3, arg4, arg5)).grid(row=14, column=2, sticky=W) Button(rightFrame, text='Start a network', command=lambda arg1=yourip, arg2=yourport, arg3=username: self. createNewNetwork(yourip, yourport, username)).grid(row=15, column=2, sticky=W)
def install_tk_support(self, root): tksupport.install(root)
from Tkinter import * import Tkinter tk = Tkinter.Tk() frame = Tkinter.Frame(tk, relief="ridge", borderwidth=2) frame.pack(fill="both",expand=1) label = Tkinter.Label(frame, text="Hallo Welt!") label.pack(expand=1) button = Tkinter.Button(frame,text="OK",command=tk.destroy) button.pack(side="bottom") if True: tk.mainloop() else: from twisted.internet import tksupport, reactor # Install the Reactor support tksupport.install(tk) # at this point build Tk app as usual using the root object, # and start the program with "reactor.run()", and stop it # with "reactor.stop()". reactor.run()
return choice not in SPECIAL_COLORS def get_choice_text(self, choice, count): if self.needs_text_prefix(choice): return "%s: %02d" % (choice.title(), count) else: return "%02d" % (count,) def update_counts(self, countnumbers): for choice, count in countnumbers.iteritems(): self.labels[choice]["text"] = self.get_choice_text(choice, count) gui = CounterGUI() from twisted.internet import tksupport tksupport.install(gui.root) from collections import defaultdict import re from twisted.internet import protocol from twisted.words.protocols import irc from twisted.application import internet, service def require_mod(func): def wrapper(bot, user, args): if user not in MODS: return func(bot, user, args) return wrapper def require_voting(func):
def __init__(self, user, pswd, win): self.user = user self.pswd = pswd self.tk = win def buildProtocol(self, addr): p = protocol.ClientFactory.buildProtocol(self, addr) p.user = self.user l = TKLilaLauncher(self.tk, p, addr.host) self.tk.protocol('WM_DELETE_WINDOW', l.quitter) l.pack() return p if __name__ == '__main__': host = sys.argv[1] if len(sys.argv) > 1 else 'localhost' port = sys.argv[2] if len(sys.argv) > 2 else 55555 user = input('Lila username for %s: ' % host) pswd = getpass.getpass('Lila password for %s: ' % user) win = tk.Tk() win.title('Lila: %s@%s' % (user, host)) tksupport.install(win) reactor.connectTCP(host, port, LilaTKClientFactory(user, pswd, win)) reactor.run()
from Tkinter import Tk, Frame, Button, LEFT from twisted.internet import reactor, tksupport class App(object): def onQuit(self): print("Quit!") reactor.stop() def onButton(self): print("Hello!") def __init__(self, master): frame = Frame(master) frame.pack() q = Button(frame, text="Quit!", command=self.onQuit) b = Button(frame, text="Hello!", command=self.onButton) q.pack(side=LEFT) b.pack(side=LEFT) if __name__ == '__main__': root = Tk() tksupport.install(root) app = App(root) reactor.run()
if len(day) == 1: day = '0' + day if len(month) == 1: month = '0' + month if len(hour) == 1: hour = '0' + hour if len(minute) == 1: minute = '0' + minute time = datetime.datetime.strptime(day+month+hour+minute+year, "%d%m%H%M%Y") self.cxn[self.selectedADR].schedule_mag_cycle(time) def _quit(self): """ called when the window is closed.""" self.parent.quit() # stops mainloop self.parent.destroy() # this is necessary on Windows to prevent # Fatal Python Error: PyEval_RestoreThread: NULL tstate reactor.stop() if __name__ == "__main__": mstr = Tkinter.Tk() tksupport.install(mstr) app = ADRController(mstr) reactor.run()
def install_tk(app): # not tested from twisted.internet import tksupport tksupport.install(app)
#!/usr/bin/env python2.7 #-*- coding: utf-8 -*- #from tkinter import * #import future import tkinter import tkinter.ttk, tkinter.messagebox from twisted.internet import tksupport, reactor win = tkinter.Tk() # Install the Reactor support tksupport.install(win) # at this point build Tk app as usual using the root object, # and start the program with "reactor.run()", and stop it # with "reactor.stop()". # Modified Button Click Function def clickMe(): action.configure(text='Hello ' + name.get()) # Menu exit def menu_quit(): win.quit() win.destroy() reactor.stop() exit()
self.canvas.bind( "<Motion>", self.move ) self.localsnake=Snake(self.canvas,"#028002") self.remotesnakes={} def move(self, event ): if len(self.localsnake.snake)==0: self.localsnake.paint(event.x,event.y) else: px,py=self.localsnake.snake[-1] if sqrt((event.x-px)**2+(event.y-py)**2)>= 6 and self.factory is not None and self.factory.client is not None: self.factory.client.sendPosition(event.x,event.y) while sqrt((event.x-px)**2+(event.y-py)**2)>= 6: r=6/sqrt((event.x-px)**2+(event.y-py)**2) px=px+(event.x-px)*r py=py+(event.x-py)*r self.localsnake.paint(px,py) def setposition(self,uid,x,y): if uid not in self.remotesnakes: self.remotesnakes[uid]=Snake(self.canvas,"#800202") self.remotesnakes[uid].paint(x,y) master = Tk() tksupport.install(master) master.title( "Multiuser snake" ) world=World(master) world.factory=PositionFactory(world.setposition) reactor.connectTCP("localhost",8123,world.factory) print "running reactor" reactor.run()
@date: 2019/11/22 @document: 皇家战棋游戏的入口文件 ''' from twisted.internet import reactor, tksupport from .configs import HOST, PORT from .client import BCClientFactory from .login import LoginUI if __name__ == '__main__': ''' 整个运行的流程是从登录界面开始的, 如果登录成功则进入游戏开始界面, 如果无法连接网络,则提示用户是否以离线模式启动, 离线模式时,无法进入联网对战。 进入开始界面以后,用户再选择是本地对战还是网络对战, 如果是本地对战,那使用本地生成的棋盘信息和随机用户信息进行对战。 如果是网络对战,则先匹配对手,匹配到了用服务器发来的棋盘信息进行对战。 ''' # 先实例化一个登录界面 ui = LoginUI() # 初始化一个协议的工厂 factory = BCClientFactory(ui) # 连接到服务器 reactor.connectTCP(HOST, PORT, factory) # 开始运行登录界面 tksupport.install(ui) # 开始运行网络协议 reactor.run()
def mainWindow(): global main main = Tk(className='shtoom') tksupport.install(main)
from tkinter import LEFT, Button, Frame, Tk from twisted.internet import reactor, tksupport class App: def onQuit(self): print("Quit!") reactor.stop() def onButton(self): print("Hello!") def __init__(self, master): frame = Frame(master) frame.pack() q = Button(frame, text="Quit!", command=self.onQuit) b = Button(frame, text="Hello!", command=self.onButton) q.pack(side=LEFT) b.pack(side=LEFT) if __name__ == "__main__": root = Tk() tksupport.install(root) app = App(root) reactor.run()
def mainGUI(self): # Declare these variables as global so it is clear to the reader these are used elsewhere # These variables need to be global so they can be accessed within updateGUI global root global predecessor global successor global nodeID global stateOfRecipient global messageEntry # Useful log information to keep track of application state logger.info("Main UI Launched") # Initialize tkinters main window root = Tk() # This installs the tkinter object into the twisted event loop. It will no longer hijack the main loop. tksupport.install(root) # Sets the current username to the title of the application window root.title(self.peers['nodeid']['user']) # Sets the logo of the application to a lock icon root.iconbitmap('@logo.xbm') # Creates tkinter string variables which allows info on the ui to be changed dynamically # Set the default text of these string vars currentPeer = StringVar() currentPeer.set("Select a peer to message") recipitentIP = StringVar() recipitentIP.set("NULL") recipitentPORT = StringVar() recipitentPORT.set(10000) stateOfRecipient = StringVar() stateOfRecipient.set("CIRCUIT NOT CREATED") messageToSend = StringVar() messageToSend.set("Type here to send a message...") userToSearch = StringVar() userToSearch.set("Search the DHT for a user") # Initialize stringvars nodeID = StringVar() nodeID.set("DHT not intialized!") predecessor = StringVar() predecessor.set("DHT not initialized!") successor = StringVar() successor.set("DHT not initialized!") # Creation of frame for the left hand side of the UI menu_left = Frame(root, width=10, height=50) # Split the left side into upper and lower frames, then add these to the left hand side frame menu_left_upper = Frame(menu_left, width=10, height=50) menu_left_lower = Frame(menu_left, width=10, height=50) # Apply a grid layout to left upper and left lower frames menu_left_upper.grid(row=1, column=0, sticky=W) menu_left_lower.grid(row=1, column=1, sticky=W) # right area statusBarRight = Frame(root, bg="#dfdfdf") currentPeer = Label(statusBarRight, textvariable=currentPeer, bg="#dfdfdf", borderwidth=2, relief="groove") currentPeer.grid(row=2, column=1) chat_textbox = scrolledtext.ScrolledText(root, width=70, height=30, borderwidth=2, relief="groove") chat_textbox.grid(row=1, column=1) # Create logging window logging2 = scrolledtext.ScrolledText(menu_left_lower, width=50, height=30, borderwidth=2, relief="groove") logging2.grid(row=2, column=0) logging2.configure(font='TkFixedFont') # Create logging handlers # Debug handler displays useful information about the application to the user on the right hand side of the UI debug_handler = DebugHandler(logging2) # Chat handler is used to write incoming messages to the scrolling chat window on the left hand side of the UI chat_handler = ChatHandler(chat_textbox) # Logging configuration logging.basicConfig(filename='test.log', level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') """Add hander to the logger""" userInfo = logging.getLogger("1") userInfo.addHandler(debug_handler) userInfo.info("Started Application") """Add hander to the logger""" chatA = logging.getLogger("2") chatA.addHandler(chat_handler) # status bar status_frame = Frame(root, height=10) # Displays current application version version = Label(menu_left_lower, text="Version: 1.0.0", width="20", borderwidth=2, relief="groove").grid(row=0, column=0, sticky=W) # Displays the author of the application author = Label(menu_left_lower, text="Author: Jamie Clarke", width="20", borderwidth=2, relief="groove").grid(row=0, column=1, sticky=EW) # Button pressed send a search query to the network DHTSearchButton = Button( menu_left_lower, width="10", text='Search!', command=lambda arg1=userToSearch: self.searchDHT(arg1)).grid( row=1, column=1, sticky=W) # A text entry that contains the user to be searched for search_user = Entry(menu_left_lower, textvariable=userToSearch, width="80").grid(row=1, column=0, sticky=W) messageToSend.set("Type here to send a message...") # A text entry where the user can write a message to send another user messageEntry = Entry(status_frame, textvariable=messageToSend, width="80") messageEntry.grid(row=6, column=0, sticky=W) Button(status_frame, text='Send', command=lambda arg1=messageToSend: self.sendMsg(arg1)).grid( row=6, column=1, sticky=EW) # Add labels to the right status bar nodeidLabel = Label(statusBarRight, textvariable=nodeID, width=35, borderwidth=2, relief="groove").grid(row=1, column=0, sticky=W) predecessorLabel = Label(statusBarRight, textvariable=predecessor, width=35, borderwidth=2, relief="groove").grid(row=1, column=1, sticky=EW) successorLabel = Label(statusBarRight, textvariable=successor, width=35, borderwidth=2, relief="groove").grid(row=1, column=2) statusLabel = Label(statusBarRight, textvariable=stateOfRecipient, width=35, borderwidth=2, relief="groove").grid(row=1, column=3, sticky=W) # Set the grid type of the UI frames menu_left.grid(row=0, column=10, rowspan=2, sticky="nsew") statusBarRight.grid(row=0, column=1, sticky="ew") status_frame.grid(row=2, column=0, columnspan=2, rowspan=4, sticky="ew") # Configure the weights of the grid formation root.grid_rowconfigure(1, weight=1) root.grid_columnconfigure(1, weight=1) # Disable the message entry field by default. Prevent message sending without a recipitent or onion route messageEntry.config(state=DISABLED) # Begin the recursive method of updating our UI self.updateGUI()