0

I'm looking for a solution to create a front-end in python for an app. I've some experience with Tk (but it's not fundamental i would like to use wxpython) and standard widget, but now i'm in a project too complicated for me. The app is like a multimedia presentation builder or scheduler, where the elements i can use are pictures, videos, sounds, and other as command to execute something and where i decide when to start to view each element. I've not found any standard widget to use, so i've made a mockup of the interface that is similar to the multitrack audio or video editor,

the mock-up image is http://tinypic.com/r/4gqnap/5

you can see in the picture my idea: there are some channels where i can put different objects like picture, videos, serial command, and foreach i can set the moment to start and the duration. When i press play the timeline cursor goes and when it reach a begin point of object in channel, the object "start " to view or execution video or something else. i can control the timeline scroll when i'm not in play, the channel scroll to add how many channels i need. The pictures and the videos will bew viewed on other dedicated frames: each channel a frame. Exist a similar front-ent from which i could get ideas? or instructions on how to build something like it?

thank's to all.

Giorgio

gbonline
  • 101
  • 9

1 Answers1

0

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).

I usually present the Pyglet option to anyone interesting in GUI development or anything graphic wise..

Here's a short drag-n-drop example:

#!/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 >= 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()
            # ----> Note: <----
            #  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()

Here you will have to create your own objects (textboxes, sliders.. etc) but you'll have full control over them.

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.

Also, see this thread and many more on GUI discussions, what the best modules are etc:

And for Pyglet:

Community
  • 1
  • 1
Torxed
  • 22,866
  • 14
  • 82
  • 131