def show_video_modes(self): self.events.add(Event.KEYUP_Event(key=K_f, callback=self.toggle_fullscreen)) self.events.add(Event.KEYUP_Event(key=K_PAGEUP, callback=self.grow)) self.events.add(Event.KEYUP_Event(key=K_PAGEDOWN, callback=self.shrink)) self.events.add(Event.KEYUP_Event(key=K_RETURN, callback=self._quit)) s = Drawable.String(w=self, message='video', fontSize=40) s.center(y=85) s = Drawable.Stationary(w=self, sprite=s) s.draw() b1 = Widget.SpriteTextButton(self, '640 x 480', callback=self.resize640x480, group=self.events) b1.center(y=125, dx=-100) self.sprites.add(b1) b2 = Widget.SpriteTextButton(self, '800 x 600', callback=self.resize800x600, group=self.events) b2.center(y=125) self.sprites.add(b2) b3 = Widget.SpriteTextButton(self, '1024 x 768', callback=self.resize1024x768, group=self.events) b3.center(y=125, dx=100) self.sprites.add(b3) b4 = Widget.SpriteTextButton(self, 'Full/Window', callback=self.toggle_fullscreen, group=self.events) b4.center(y=165) self.sprites.add(b4) self.pause()
def subselect(self, changes=True): self.save_mem() # maybe 'can' modify children ... # poñer dentro de changes ? self.struct.apply_to_all_plots(self.window.panelB.update) if changes: self.struct.call_influences( self.window.panelB.update_from_dependency ) # 'punteiros inversos' offset = self.combobox.GetSelection() children = self.struct.get_children() # event if not self.is_leaf: if (offset != wx.NOT_FOUND and offset >= 0 and offset < len(children)): evt = Widget.EventStructChange(self.GetId(), index=self.index + 1, struct=children[offset]) wx.PostEvent(self, evt) else: evt = Widget.EventStructChange(self.GetId(), index=self.index + 1, struct=None) wx.PostEvent(self, evt)
def panelbar(self): handle = self.server.get(self.handle, 'panelbar') if handle: try: return self.getWidget(handle) except KeyError: return Widget.Widget(self.server, handle, self)
def instantiate(self, importList=[]): h = self.app.server.dup(self.handle) w = Widget.Widget(self.app.server, h, self.app) self.instances.append(w) for name in importList: attrName = name.replace(' ','_') setattr(w,attrName,w.find(name)) w.importList = importList return w
def link(self, handler, widget=None, evname=None): if type(widget) == type(''): evname = widget widget = None if type(widget) in (type(0), type(0L)): try: widget = self.getWidget(widget) except KeyError: widget = Widget.Widget(self.server, widget, self)
def create_tree(): #initialize start state and widgets w1 = Widget.Widget('AEDCA') w2 = Widget.Widget('BEACD') w3 = Widget.Widget('BABCE') w4 = Widget.Widget('DADBD') w5 = Widget.Widget('BECBD') start_state = Planning.State('start', start_dist, {1:w1, 2:w2,3:w3, 4:w4,5:w5 }) #create root root = PlanTree(start_state) #create children root.A = create_child(root.data.vars,distances_A,'A') root.B = create_child(root.data.vars,distances_B,'B') root.C = create_child(root.data.vars,distances_C,'C') root.D = create_child(root.data.vars,distances_D,'D') root.E = create_child(root.data.vars,distances_E,'E') # return the root return root
def startSlide(e): self._isMouseDown=True self._upperBound = self._div_shell.offsetWidth - self._handle.offsetWidth pos = Widget.getMousePosition(e) self._startMouseX=pos['x'] self._lastElementLeft = parseInt(self._handle.elt.style.left) #- parseInt(self._div_shell.elt.style.left) #print(self._upperBound) updatePosition(e)
def updatePosition(e): pos = Widget.getMousePosition(e) _newPos = self._lastElementLeft + pos['x'] - self._startMouseX _newPos = max(0, _newPos) _newPos = min(_newPos, self._upperBound) #print(_newPos) self._handle.elt.style.left = '%spx' % _newPos self._lastElementLeft = _newPos
def add_widget(self, widget_type, name, x, y, width, height, z=0, transparent=False): if width > 0 and height > 0: if widget_type in ('rect', 'Rect'): self.widgets[name] = Widget.Rect(name, x, y, width, height, z, transparent) elif widget_type in ('text', 'Text'): self.widgets[name] = Widget.Text(name, x, y, width, height, z, transparent) elif widget_type in ('textbox', 'Textbox'): self.widgets[name] = Widget.Textbox(name, x, y, width, height, z, transparent) elif widget_type in ('gradient', 'Gradient'): self.widgets[name] = Widget.Gradient(name, x, y, width, height, z, transparent) elif widget_type in ('variable', 'Variable'): self.widgets[name] = Widget.Variable(name, x, y, width, height, z, transparent) elif widget_type in ('diagram', 'Diagram'): self.widgets[name] = Widget.Diagram(name, x, y, width, height, z, transparent) elif widget_type in ('bar', 'Bar'): self.widgets[name] = Widget.Bar(name, x, y, width, height, z, transparent) elif widget_type in ('ellipse', 'Ellipse'): self.widgets[name] = Widget.Ellipse(name, x, y, width, height, z, transparent) elif widget_type in ('container', 'Container'): self.widgets[name] = Container(name, x, y, width, height, z, transparent) elif widget_type in ('table', 'Table'): self.widgets[name] = Widget.Table(name, x, y, width, height, z, transparent) else: raise ValueError( "add_widget() called from Container with unknown widget_type: widget_type = " + widget_type) else: raise ValueError( "[Warning] add_widget() called from Container with illegal width and height: (" + str(width) + ", " + str(height) + ")")
def startSlide(e): self._isMouseDown = True self._upperBound = self._div_shell.offsetWidth - self._handle.offsetWidth pos = Widget.getMousePosition(e) self._startMouseX = pos['x'] self._lastElementLeft = parseInt( self._handle.elt.style.left ) #- parseInt(self._div_shell.elt.style.left) #print(self._upperBound) updatePosition(e)
def __init__(self, game): self.game = game w, h = conf.WINSIZE w = int(0.5 * w) h = int(0.8 * h) Drawable.Layer.__init__(self, size=(w, h)) GameLooper.__init__(self) self.sprites = self.addGroup(layer=self) self.events.add(Event.KEYUP_Event(key=K_ESCAPE, callback=self._stop)) self.set_background(color=BLACK) self.border(width=3, color=RED) s = Drawable.String(w=self, message='configuration', fontSize=40) s.center(y=15) #print 1, s.get_position() s = Drawable.Stationary(w=self, sprite=s) s.draw() self.center() #print 2, self.get_position() q = Widget.SpriteTextButton(self, 'QUIT', callback=self._quit, group=self.events) q.center(y=50) self.sprites.add(q) cl = Widget.CloseButton(self, callback=self._stop, group=self.events) self.events.add(Event.KEYUP_Event(key=K_s, callback=self.save_config)) save = Widget.SpriteTextButton(self, 'Save', callback=self.save_config, group=self.events) save.center(y=-50) self.sprites.add(save) self.show_video_modes()
def poll_next_event(self, timeout=None): ev = self.server.wait(timeout) if ev is None: return if ev.widget_id is None: if ev.name == 'infilter': ev = ev.trigger try: ev.widget = self._infilter_registry[ev.sender] except KeyError: ev.widget = self else: ev.widget = None else: try: ev.widget = self._widget_registry[ev.widget_id] except KeyError: ev.widget = Widget.Widget(self.server, ev.widget_id) self._event_stack.append(ev)
class WidgetTestCase(unittest.TestCase): def setUp(self): self.widget = Widget() def tearDown(self): self.widget.dispose() self.widget = None def testSize(self): self.assertEqual(self.widget.getSize(), (40, 40)) def testResize(self): self.widget.resize(100, 100) self.assertEqual(self.widget.getSize(), (100, 100))
def setUp(self): self.widget = Widget.Widget()
# try: # Execute start-up procedures and receive Device instance and label str label = startup_screen(dev, HEADER) except: log.exception("Start-up procedures failed!") print("Program execution terminated abnormally. See 'pbbes.log'") os._exit(-1) # # Create Main UI and start executing # try: # Initialize curses stdscr = Widget.init() # Setup event scheduler (IntervalWidget needs it) event = IntervalScheduler( Config.Heartbeat, Config.Interval, Config.Timewindow ) # Create (and draw) Widgets with \ Widget.TableWidget(device = dev) as tbl, \ Widget.PWMLabelWidget() as lbl, \ Widget.PWMWidget(device = dev, channel = 1) as pwm1, \ Widget.PWMWidget(device = dev, channel = 2) as pwm2, \ Widget.PWMWidget(device = dev, channel = 3) as pwm3, \
import sys from PyQt5 import QtCore, QtGui, QtWidgets import Widget import test_rc app = QtWidgets.QApplication(sys.argv) window = Widget.QmyWidget() window.show() sys.exit(app.exec())
# along with pygsear; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Objects used for network communication using Twisted More information available at http://twistedmatrix.com/ """ try: import twisted except ImportError: import Widget msg = """Game requires Twisted Python for networking see http://twistedmatrix.com/ for information""" dlg = Widget.Dialog_OK(message=msg) dlg.modal() raise ImportError, "Error importing twisted modules" from twisted.internet import reactor from twisted.spread import pb class TwoPlayerConnection(pb.Root, pb.Referenceable): """Simple two player network connector First tries to connect to an existing server, and if none is found, will then wait for an incoming connection. """ def __init__(self, game):
try: from PySide import QtCore, QtGui except ImportError: from PyQt4 import QtCore, QtGui if __name__ == "__main__": App = QtGui.QApplication(sys.argv) Midi.startup() globals = GlobalSettings() TPlayer = Player(globals) TWidget = Widget(TPlayer,globals) TPanel = TWidget.panel TPlayer.set_panel(TPanel) if len(TPlayer.behaviournames) <= 0: print "Hey!? No behaviours in %s !?" % globals.settings_dir(settingsname) sys.exit(1) bn = TPlayer.behaviournames[0] TPanel.change_behaviour(bn, True) TPanel.write_file_onchange = True oscmon = OscMonitor("127.0.0.1", globals.tuioport) oscmon.setcallback(TPlayer.mycallback, "")
def test_default_widget_size(self): widget = w.Widget('The widget') self.assertEqual(widget.size(), (50, 50))te
#! /usr/bin/env python # -*- coding:utf-8 -*- # # Camera calibration application # # External dependencies import sys from PyQt5 import QtWidgets import Widget # Main application if __name__ == '__main__': application = QtWidgets.QApplication(sys.argv) widget = Widget.CameraCalibrationWidget() widget.show() sys.exit(application.exec_())
import Planning import Widget import PlanTree import graph #part 1 Q1 w1 = Widget.Widget('AEDCA') w2 = Widget.Widget('BEACD') w3 = Widget.Widget('BABCE') w4 = Widget.Widget('DADBD') w5 = Widget.Widget('BECBD') short_graph = graph.Graph() short_graph.edges = { 'start': ['A', 'B', 'C', 'D', 'E'], 'A': ['B', 'C', 'D', 'E'], 'B': ['A', 'C', 'D', 'E'], 'C': ['A', 'B', 'D', 'E'], 'D': ['A', 'B', 'C', 'E'], 'E': ['A', 'B', 'C', 'D'] } short_graph.weights = { 'start': { 'A': 1, 'B': 1, 'C': 1, 'D': 1, 'E': 1 }, 'A': { 'B': 1, 'C': 1,