Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is a extreeemely vague question.. But here we go.. I'd skip most of the traditional modules (such as Tk or wxPython but they could work for you).</p> <p>I usually present the Pyglet option to anyone interesting in GUI development or anything graphic wise..</p> <p>Here's a short drag-n-drop example:</p> <pre><code>#!/usr/bin/python import pyglet from time import time, sleep class Window(pyglet.window.Window): def __init__(self, refreshrate): super(Window, self).__init__(vsync = False) self.frames = 0 self.framerate = pyglet.text.Label(text='Unknown', font_name='Verdana', font_size=8, x=10, y=10, color=(255,255,255,255)) self.last = time() self.alive = 1 self.refreshrate = refreshrate self.click = None self.drag = False def on_draw(self): self.render() def on_mouse_press(self, x, y, button, modifiers): self.click = x,y def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers): if self.click: self.drag = True print 'Drag offset:',(dx,dy) def on_mouse_release(self, x, y, button, modifiers): if not self.drag and self.click: print 'You clicked here', self.click, 'Relese point:',(x,y) else: print 'You draged from', self.click, 'to:',(x,y) self.click = None self.drag = False def render(self): self.clear() if time() - self.last &gt;= 1: self.framerate.text = str(self.frames) self.frames = 0 self.last = time() else: self.frames += 1 self.framerate.draw() self.flip() def on_close(self): self.alive = 0 def run(self): while self.alive: self.render() # ----&gt; Note: &lt;---- # Without self.dispatc_events() the screen will freeze # due to the fact that i don't call pyglet.app.run(), # because i like to have the control when and what locks # the application, since pyglet.app.run() is a locking call. event = self.dispatch_events() sleep(1.0/self.refreshrate) win = Window(23) # set the fps win.run() </code></pre> <p>Here you will have to create your own objects (textboxes, sliders.. etc) but you'll have <strong>full</strong> control over them.</p> <p>I've built a few (8-13) large-scale GUI applications and this is the cleanest way to go if you don't want to use brick looking buttons and generic colorschemes.</p> <p>Also, see this thread and many more on GUI discussions, what the best modules are etc:</p> <ul> <li><a href="http://wiki.python.org/moin/GuiProgramming" rel="nofollow noreferrer">http://wiki.python.org/moin/GuiProgramming</a></li> <li><a href="https://stackoverflow.com/questions/15896460/game-development-in-python-ruby-or-lua/15896508#15896508">Game Development in Python, ruby or LUA?</a></li> <li><a href="https://stackoverflow.com/questions/14779486/curses-alternative-for-windows/14779649#14779649">Curses alternative for windows</a> (some other code i know i've given away)</li> </ul> <p>And for Pyglet:</p> <ul> <li><a href="http://www.pyglet.org/" rel="nofollow noreferrer">http://www.pyglet.org/</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload