def setUp(self):
""" Initialize GUI and GUI elements """
# Create video thread
self.videoThread = video.VideoThread()
self.videoThread.start()
# Create and start GUI
self.guiThread = gui.GUI()
self.guiThread.start(self.videoThread)
# Get window
self.mainWindow = self.guiThread.get_window()
# Get GUI elements
self.toolbar_roi = self.mainWindow.get_toolbar_roi()
self.toolbar_buttons = self.mainWindow.get_toolbar_buttons()
self.statusbar = self.mainWindow.get_statusbar()
self.winSignal = self.mainWindow.get_signal_display()
self.winVideo = self.mainWindow.get_video_display()
python类GUI的实例源码
def test_gui_ToolbarROI_set_roi_in_gui(self):
"""Check if ROI values can be set using GUI"""
self.toolbar_roi.set_roi(0, 255, 0, 255)
assert_equal(self.toolbar_roi.x_min, 0)
assert_equal(self.toolbar_roi.x_max, 255)
assert_equal(self.toolbar_roi.y_min, 0)
assert_equal(self.toolbar_roi.y_max, 255)
def __init__(self):
self.display = gui.GUI(self.root, self, self.board, self.player_turns)
self.display.pack(
side='top', fill='both', expand='true', padx=4, pady=4)
def __init__(self,
pen_down_action=None,
pen_up_action=None,
pen_drag_action=None):
super(Plotter, self).__init__()
if not pen_down_action:
def pen_down_action(location):
return
if not pen_up_action:
def pen_up_action(location):
return
if not pen_drag_action:
def pen_drag_action(location):
return
self.anoto = Anoto()
self.ems = EMS()
self.gui = GUI()
self.model = ReachModel(self.ems, self.gui)
self.active_models = []
def anoto_callback(addr, tags, pen_data, source):
speed = self.anoto.speed.get_vector()
self.model.stats.feed_data(speed, pen_data)
self.model.stats.feed_anoto_time(time.time())
if pen_data[2] == "down":
self.ems.EMS_ON = True
self.model.stats.resume_timer()
location = (pen_data[0], pen_data[1])
self.gui.mark_pen_down(location)
pen_down_action(location)
# print('Anoto: Pen Down')
elif pen_data[2] == "up":
self.ems.EMS_ON = False
self.model.stats.pause_timer()
self.model.handle_penup()
self.anoto.speed.reset_measure()
location = (pen_data[0], pen_data[1])
self.gui.mark_pen_up(location)
pen_up_action(location)
# print('Anoto: Pen Up')
elif pen_data[2] == "drag":
location = (pen_data[0], pen_data[1])
self.gui.mark_pen_drag(location)
pen_drag_action(location)
# print('Anoto: Pen Drag')
self.anoto.set_callback_function(anoto_callback)
self.anoto.start_osc_server()
def getOptions():
'''
Analizu datumoj
'''
args = argv[1:]
parser = argparse.ArgumentParser(description="Parses command.",argument_default=argparse.SUPPRESS)
parser.add_argument("project",nargs="?")
parser.add_argument("-c", "--config",nargs="?",dest='config',
help="Optional path to a non-default config file.")
parser.add_argument("-l", "--logfile",nargs="?",dest='logfile',
help="Optional path to log file. Default is /tmp")
parser.add_argument("-v", "--verbose",dest='verbose',action='store_true',help="Print debugging to terminal.")
#parser.add_argument("-w", "--which",dest='which',action='store_true',help="Print version to terminal.")
parser.add_argument("-s", "--shell",dest='shell',action='store_true',help="Keep it in the shell. Do not launch the GUI.")
parser.add_argument("-m", "--make-project",nargs="?",dest='make',
help="Path to a directory of sequential images to load as if it were a StopGo project.")
options = parser.parse_args(args)
opts = vars(options)
'''
if not opts.has_key('project'):
opts['project'] = 'stopgo_project.db'
if not opts.has_key('config'):
if os.path.isfile( os.path.join( HOME + '.config/stopgo.conf' ) ):
opts['config'] = os.path.isfile( os.path.join( HOME + '/.config/stopgo.conf' ) ):
elif os.path.isfile('/etc/config/stopgo.conf'):
opts['config'] = '/etc/config/stopgo.conf'
else:
print('Failed: No template file found.')
exit()
'''
if not opts.has_key('shell'):
import gui
gui.main(opts)
#applo = wx.App()
#instancer = gui.GUI(parent=None, id=-1, title="stopgo")
#instancer.Show()
#applo.MainLoop()
else:
import shell
shell.execute(opts)