def __init__(self, pSize, pApp): tbl = gui.Table(width=pSize['w'], height=pSize['c_h']) # text on the left tbl2 = gui.Table() tbl2.tr() txt = _("To ckeck operation\n" "Aim gun sight at monitor\n" "Move gun within monitor boundary.\n" "Ensure IR point is visible\n" "to the gun when aimed\n" "at all areas of the screen.") lines = txt.split("\n") for line in lines: tbl2.tr() tbl2.td(gui.Label(str(line))) txtTbl = gui.Table(height=pSize['ir_h']) txtTbl.tr() txtTbl.td(tbl2, style={'border':1}) # legend tbl2 = gui.Table() tbl2.tr() tbl2.td(gui.Color(width=30,height=30, value=(255,0,0))) tbl2.td(gui.Label(" "+_('IR Good')), align=-1) tbl2.tr() tbl2.td(gui.Spacer(10,10)) tbl2.tr() tbl2.td(gui.Color(width=30,height=30, value=(255,165,0))) tbl2.td(gui.Label(" "+_('IR Good but faint')), align=-1) tbl2.tr() tbl2.td(gui.Spacer(10,10)) tbl2.tr() tbl2.td(gui.Color(width=30,height=30, value=(0,0,0))) tbl2.td(gui.Label(" "+_('IR Not visible')), align=-1) txtTbl.tr() txtTbl.td(gui.Spacer(10,10)) txtTbl.tr() txtTbl.td(tbl2, style={'border':1}) # test area self.tstArea = IrTest(width=pSize['ir_w'], height=pSize['ir_h']) # calibrate button btn = gui.Button(_('Calibrate')) btn.connect(gui.CLICK, pApp.startCal, None) tbl.tr() tbl.td(txtTbl) tbl.td(self.tstArea) tbl.tr() tbl.td(btn, colspan=2) self.widget = tbl
def __init__(self,value,**params): self.value = list(gui.parse_color(value)) title = gui.Label("Color Picker") main = gui.Table() main.tr() self.color = gui.Color(self.value,width=64,height=64) main.td(self.color,rowspan=3,colspan=1) ##The sliders CHANGE events are connected to the adjust method. The ##adjust method updates the proper color component based on the value ##passed to the method. ##:: main.td(gui.Label(' Red: '),1,0) e = gui.HSlider(value=self.value[0],min=0,max=255,size=32,width=128,height=16) e.connect(gui.CHANGE,self.adjust,(0,e)) main.td(e,2,0) ## main.td(gui.Label(' Green: '),1,1) e = gui.HSlider(value=self.value[1],min=0,max=255,size=32,width=128,height=16) e.connect(gui.CHANGE,self.adjust,(1,e)) main.td(e,2,1) main.td(gui.Label(' Blue: '),1,2) e = gui.HSlider(value=self.value[2],min=0,max=255,size=32,width=128,height=16) e.connect(gui.CHANGE,self.adjust,(2,e)) main.td(e,2,2) gui.Dialog.__init__(self,title,main)
def __init__(self, value, on_open=None, on_close=None, **params): self._on_open = [] self._on_close = [] if on_open: self._on_open.append(on_open) if on_close: self._on_close.append(on_close) self.value = list(gui.parse_color(value)) title = gui.Label('Color Picker') main = gui.Table() main.tr() self.color = gui.Color(self.value, width=64, height=64) main.td(self.color, rowspan=3, colspan=1) main.td(gui.Label(' Red: '), 1, 0) e = gui.HSlider(value=self.value[0], min=0, max=255, size=32, width=128, height=16) e.connect(gui.CHANGE, self.adjust, (0, e)) main.td(e, 2, 0) main.td(gui.Label(' Green: '), 1, 1) e = gui.HSlider(value=self.value[1], min=0, max=255, size=32, width=128, height=16) e.connect(gui.CHANGE, self.adjust, (1, e)) main.td(e, 2, 1) main.td(gui.Label(' Blue: '), 1, 2) e = gui.HSlider(value=self.value[2], min=0, max=255, size=32, width=128, height=16) e.connect(gui.CHANGE, self.adjust, (2, e)) main.td(e, 2, 2) gui.Dialog.__init__(self, title, main, **params)
def __init__(self,**params): gui.Desktop.__init__(self,**params) self.connect(gui.QUIT,self.quit,None) c = gui.Container(width=940,height=980) spacer = 8 self.fname = 'untitled.tga' self.new_d = NewDialog() self.new_d.connect(gui.CHANGE,self.action_new,None) self.open_d = OpenDialog() self.open_d.connect(gui.CHANGE,self.action_open,None) self.save_d = SaveDialog() self.save_d.connect(gui.CHANGE,self.action_saveas,None) self.quit_d = QuitDialog() self.quit_d.connect(QUIT,self.quit,None) self.help_d = HelpDialog() self.about_d = AboutDialog() ##Initializing the Menus, we connect to a number of Dialog.open methods for each of the dialogs. ##:: menus = gui.Menus([ ('File/New',self.new_d.open,None), ('File/Open',self.open_d.open,None), ('File/Save',self.action_save,None), ('File/Save As',self.save_d.open,None), ('File/Exit',self.quit_d.open,None), ('Help/Help',self.help_d.open,None), ('Help/About',self.about_d.open,None), ]) ## c.add(menus,0,0) menus.rect.w,menus.rect.h = menus.resize() #print 'menus',menus.rect ##We utilize a Toolbox. The value of this widget determins how drawing is done in the Painter class. ##:: self.mode = mode = gui.Toolbox([ ('Draw','draw'), ('Box','box'), ('Circle','circle'), ('Cuzco','cuzco'), ],cols=1,value='draw') ## c.add(mode,0,menus.rect.bottom+spacer) mode.rect.x,mode.rect.y = mode.style.x,mode.style.y mode.rect.w,mode.rect.h = mode.resize() #mode._resize() default = "#000000" self.color = color = gui.Color(default,width=mode.rect.w,height=mode.rect.w) self.color_d = ColorDialog(default) color.connect(gui.CLICK,self.color_d.open,None) # Updates the toolbox color picker with the value in the color dialog box def change_cb(*args): self.color.value = self.color_d.value self.color_d.connect(gui.CHANGE, change_cb) c.add(self.color,0,mode.rect.bottom+spacer) self.color.rect.w,self.color.rect.h = self.color.resize() #self.color._resize() self.painter = Painter(width=c.rect.w-mode.rect.w-spacer*2,height=c.rect.h-menus.rect.h-spacer*2,style={'border':1}) c.add(self.painter,mode.rect.w+spacer,menus.rect.h+spacer) self.painter.init({'width':956,'height':956,'color':'#ffffff'}) self.painter.rect.w,self.painter.rect.h = self.painter.resize() #self.painter._resize() welcome_d = WelcomeDialog() self.connect(gui.INIT,welcome_d.open,None) self.widget = c
def __init__(self,**params): title = gui.Label("New Picture...") ##Once a form is created, all the widgets that are added with a name ##are added to that form. ##:: self.value = gui.Form() t = gui.Table() t.tr() t.td(gui.Label("Size"),align=0,colspan=2) tt = gui.Table() tt.tr() tt.td(gui.Label("Width: "),align=1) tt.td(gui.Input(name="width",value=256,size=4)) tt.tr() tt.td(gui.Label("Height: "),align=1) tt.td(gui.Input(name="height",value=256,size=4)) t.tr() t.td(tt,colspan=2) ## t.tr() t.td(gui.Spacer(width=8,height=8)) t.tr() t.td(gui.Label("Format",align=0)) t.td(gui.Label("Background",align=0)) t.tr() g = gui.Group(name="format",value="rgb") tt = gui.Table() tt.tr() tt.td(gui.Radio(g,value="rgb")) tt.td(gui.Label(" RGB"),align=-1) tt.tr() tt.td(gui.Radio(g,value="bw")) tt.td(gui.Label(" Grayscale"),align=-1) t.td(tt,colspan=1) g = gui.Group(name="color",value="#ffffff") tt = gui.Table() tt.tr() tt.td(gui.Radio(g,value="#000000")) tt.td(gui.Label(" Black"),align=-1) tt.tr() tt.td(gui.Radio(g,value="#ffffff")) tt.td(gui.Label(" White"),align=-1) tt.tr() default = "#ffffff" radio = gui.Radio(g,value="custom") color = gui.Color(default,width=40,height=16,name="custom") picker = ColorDialog(default) color.connect(gui.CLICK,gui.action_open,{'container':t,'window':picker}) picker.connect(gui.CHANGE,gui.action_setvalue,(picker,color)) tt.td(radio) tt.td(color) t.td(tt,colspan=1) t.tr() t.td(gui.Spacer(width=8,height=8)) ##The okay button CLICK event is connected to the Dailog's ##send event method. It will send a gui.CHANGE event. ##:: t.tr() e = gui.Button("Okay") e.connect(gui.CLICK,self.send,gui.CHANGE) t.td(e) ## e = gui.Button("Cancel") e.connect(gui.CLICK,self.close,None) t.td(e) gui.Dialog.__init__(self,title,t)
def __init__(self,**params): gui.Table.__init__(self,**params) def fullscreen_changed(btn): #pygame.display.toggle_fullscreen() print("TOGGLE FULLSCREEN") def stars_changed(slider): n = slider.value - len(stars) if n < 0: for i in range(n,0): stars.pop() else: for i in range(0,n): stars.append([random.randrange(-WIDTH*span,WIDTH*span), random.randrange(-HEIGHT*span,HEIGHT*span), random.randrange(1,dist)]) fg = (255,255,255) self.tr() self.td(gui.Label("Phil's Pygame GUI",color=fg),colspan=2) self.tr() self.td(gui.Label("Speed: ",color=fg),align=1) e = gui.HSlider(100,-500,500,size=20,width=100,height=16,name='speed') self.td(e) self.tr() self.td(gui.Label("Size: ",color=fg),align=1) e = gui.HSlider(2,1,5,size=20,width=100,height=16,name='size') self.td(e) self.tr() self.td(gui.Label("Quantity: ",color=fg),align=1) e = gui.HSlider(100,1,1000,size=20,width=100,height=16,name='quantity') e.connect(gui.CHANGE, stars_changed, e) self.td(e) self.tr() self.td(gui.Label("Color: ",color=fg),align=1) default = "#ffffff" color = gui.Color(default,width=64,height=10,name='color') color_d = ColorDialog(default) color.connect(gui.CLICK,color_d.open,None) self.td(color) def update_col(): color.value = color_d.value color_d.connect(gui.CHANGE,update_col) btn = gui.Switch(value=False,name='fullscreen') btn.connect(gui.CHANGE, fullscreen_changed, btn) self.tr() self.td(gui.Label("Full Screen: ",color=fg),align=1) self.td(btn) self.tr() self.td(gui.Label("Warp Speed: ",color=fg),align=1) self.td(gui.Switch(value=False,name='warp'))