Ejemplo n.º 1
0
	def run(self):
		self.frame = slew.Frame()
		scene = slew.SceneView(bgcolor=(64,64,64))
		for i in xrange(0, 100):
			scene.append(Item(i))
		self.frame.append(slew.VBox().append(scene))
		self.frame.show()
Ejemplo n.º 2
0
    def run(self):
        xml = """
			<frame title="Hello">
				<vbox>
					<label align="center">Hello world!</label>
				</vbox>
			</frame>
		"""
        frame = slew.Frame(xml)
        frame.show()
Ejemplo n.º 3
0
    def run(self):
        self.f = slew.Frame(xml)
        for n in ['setup', 'preview', 'print', 'pdf']:
            self.f.find(n).handler = Handler()

        scene = self.f.find('view')
        scene.handler = ViewHandler()

        # 		scene.set_align(slew.ALIGN_TOP | slew.ALIGN_LEFT)
        scene.append(SceneItem(size=(2100, 2970)))

        print slew.get_screen_dpi()
        scale = slew.get_screen_dpi().x / 254  # 100%
        scene.set_scale(scale)

        slew.chain_debug_handler(self.f, True,
                                 'onDrag* onMouseWheel onDblClick')
        self.f.show()
Ejemplo n.º 4
0
 def run(self):
     frame = slew.Frame(title="Hello")
     frame.append(slew.VBox())
     frame[0].append(
         slew.Label(text="Hello world!", align=slew.ALIGN_CENTER))
     frame.show()
Ejemplo n.º 5
0
 def run(self):
     self.frame = slew.Frame()
     grid = slew.Grid()
     grid.set_model(Model())
     self.frame.append(slew.VBox().append(grid))
     self.frame.show()
Ejemplo n.º 6
0
Archivo: dnd.py Proyecto: amottola/slew
 def run(self):
     self.frame = slew.Frame()
     pict = slew.Image(size=(300, 300))
     pict.set_handler(Handler())
     self.frame.append(slew.VBox(margins=20).append(pict))
     self.frame.show()
Ejemplo n.º 7
0
    def run(self):
        def slider_h(e):
            print "slider changed:", e.value, e.widget.get_min(
            ), e.widget.get_max()

        def radio_h(e):
            frame = e.widget.get_parent_frame()
            print "selected radio:", frame.get_radio('abc').get_name()

        class popup_h(slew.EventHandler):
            def __init__(self, f):
                self.f = f

            def onClick(self, e):
                self.p = slew.PopupWindow()
                self.p.append(slew.Sizer().append(slew.Calendar()))
                self.p.popup(e.widget, (0, e.widget.size.h))

                def clicked(e):
                    print "selected date:", e.date

                self.p[0][0].onClick = clicked
                print "popped up"

        self.clones = []
        self.f = slew.Frame(xml, globals(), locals())
        # 		self.f = slew.Frame(xml, globals(), locals(), title="Prova!", size=(500,500), minsize=(100,100))
        self.f.handler = Handler()
        button = self.f.find('menu_button')
        button.handler = Handler()
        button.set_menu(slew.Menu(menu2_xml))
        # 		button.set_pos((0,0))
        button.set_margins(20)
        print button.get_margins()
        button = self.f.find('clone_button')

        def clone(e):
            self.clones.append(self.f.clone())
            self.clones[-1].show()

        button.onClick = clone

        # 		self.statusbar = slew.MenuBar(menu_xml)
        # 		self.statusbar = slew.ToolBar(toolbar_xml)
        self.statusbar = slew.SizerItem(sizer_xml)

        # 		self.statusbar.append(slew.ToolButton(size=(20,20), label="+"))
        # 		self.statusbar.append(slew.ToolButton(size=(20,20), label="-"))
        self.current = None

        def move(e):
            if self.current is None:
                self.current = 0
            else:
                self.current += 1
            if self.current >= len(self.clones):
                self.current = 0
            print "moving to", self.current
            sizer = self.clones[self.current].find('sizer')
            sizer.append(self.statusbar)

        button = self.f.find('move_button')
        button.onClick = move

        # 		slew.set_shortcut("esc", lambda: slew.exit())

        # 		self.f.find('slider').onChange = slider_h

        self.f.find('icons').model = IconsModel()
        self.f.find('icons').handler = IconsHandler()

        self.f.find('grid').model = MyModel()  #GridModel()
        # 		self.f.find('grid').handler = GridHandler()

        self.f.find('popup').handler = popup_h(self.f)

        # 		slew.chain_debug_handler(self.f, True, 'onModify onFocus* onSelect onDblClick onContextMenu onChange onClick onCancel onEnter onCell*')
        # 		slew.chain_debug_handler(self.f, True, 'onModify onFocus* onCell* onDrag*')
        # 		slew.chain_debug_handler(self.f, True, 'onCell*')# onFocus* onChange*')

        self.f.center()
        self.f.show()

        tf = self.f.find('textfield')
        tf.set_completer(slew.Completer(CompleterModel()))

        def complete(e):
            print 'textfield onChange', e
            if (e.completion < 0) and len(e.value):
                tf.complete()

        def focus_out(e):
            print "focus out!", e.widget
            if isinstance(e.widget, slew.Grid):
                return e.widget.popup_message("Hello world! ",
                                              align=slew.RIGHT,
                                              buttons=slew.BUTTON_OK
                                              | slew.BUTTON_CANCEL,
                                              index=e.index) == slew.BUTTON_OK
            else:
                return e.widget.popup_message(
                    "Hello world! ",
                    align=slew.RIGHT,
                    buttons=slew.BUTTON_OK
                    | slew.BUTTON_CANCEL) == slew.BUTTON_OK

        tf.onChange = complete
        tf.onFocusOut = focus_out
        # 		self.f.find('grid').onCellEditEnd = focus_out

        print self.f.find('combo').items
Ejemplo n.º 8
0
 def run(self):
     slew.Frame(xml, globals=globals()).show()