def create_circle(self, touch): # create the circle image circle = Image(source=self.app.config.get('Advanced', 'CircleImage'), color=CIRCLE_IMAGE_COLOR, allow_stretch=True, size=(self.app.config.getint('Advanced', 'CircleSize'), self.app.config.getint('Advanced', 'CircleSize'))) # center the circle on the finger position circle.x = touch.x - circle.size[0] / 2 circle.y = touch.y - circle.size[1] / 2 self.add_widget(circle) # and just right fade it out after having displayed it animation = Animation( color=CIRCLE_IMAGE_COLOR_TRANSPARENT, size=(self.app.config.getint('Advanced', 'CircleSize') * 2, self.app.config.getint('Advanced', 'CircleSize') * 2), x=circle.pos[0] - (self.app.config.getint('Advanced', 'CircleSize') / 2), # workaround for centering the image during resizing y=circle.pos[1] - (self.app.config.getint('Advanced', 'CircleSize') / 2), # workaround for centering the image during resizing t='out_expo', duration=CIRCLE_IMAGE_FADEOUT_TIME) animation.start(circle) animation.bind(on_complete=self.circle_fadeout_complete)
def build(self): self.title = "Blackjack" self.parent = Widget() sm = ScreenManager() # set up the screens #splashcreen self.ss = Screen(name = 'splash_screen') splashmenu = SplashScreen() splashmenu.buildUp() self.ss.add_widget(splashmenu) #main menu self.mm = Screen(name = 'main_menu') self.mainmenu = MainMenu() self.mainmenu.buildUp() self.mm.add_widget(self.mainmenu) #add the logo to mainmenu and splashscreen logo = Image(source = 'images/logo.png') logo.width = Window.width/2 logo.height = Window.height/2 logo.x = Window.width/2 - (logo.width-logo.width*.05) logo.y = (Window.height/2 - logo.width/2) self.mm.add_widget(logo) #game screen self.gs = Game(name = 'game') #Add screens to screen manager sm.add_widget(self.ss) sm.add_widget(self.mm) sm.add_widget(self.gs) sm.current = 'main_menu' def check_screen_change(obj): if(self.mainmenu.buttonText == 'Play'): sm.current = 'game' self.gs.start_round() self.mainmenu.bind(on_button_release = check_screen_change) return sm
def create_blob(self, touch): # define a short name for the touch-specific and unique UserDictionary "ud" ud = touch.ud # create the new blob ud['blob'] = Image( source=self.parent.app.config.get('Advanced', 'BlobImage'), color=BLOB_IMAGE_COLOR, allow_stretch=True, size=(self.parent.app.config.getint('Advanced', 'BlobSize'), self.parent.app.config.getint('Advanced', 'BlobSize'))) # set the blobs position right under the finger ud['blob'].x = touch.x - ud['blob'].size[0] / 2 ud['blob'].y = touch.y - ud['blob'].size[1] / 2 self.add_widget(ud['blob'])
def create_circle(self, touch): # create the circle image circle = Image( source=self.app.config.get('Advanced', 'CircleImage'), color=CIRCLE_IMAGE_COLOR, allow_stretch=True, size=(self.app.config.getint('Advanced', 'CircleSize'), self.app.config.getint('Advanced', 'CircleSize'))) # center the circle on the finger position circle.x = touch.x - circle.size[0] / 2 circle.y = touch.y - circle.size[1] / 2 self.add_widget(circle) # and just right fade it out after having displayed it animation = Animation( color=CIRCLE_IMAGE_COLOR_TRANSPARENT, size=(self.app.config.getint('Advanced', 'CircleSize') * 2, self.app.config.getint('Advanced', 'CircleSize') * 2), x=circle.pos[0] - (self.app.config.getint('Advanced', 'CircleSize')/2), # workaround for centering the image during resizing y=circle.pos[1] - (self.app.config.getint('Advanced', 'CircleSize')/2), # workaround for centering the image during resizing t='out_expo', duration=CIRCLE_IMAGE_FADEOUT_TIME) animation.start(circle) animation.bind(on_complete=self.circle_fadeout_complete)
def rebuild(self): self.clear_all() b2 = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) b3 = BoxLayout(orientation='horizontal', size_hint=(1, 0.1)) but_off = Button(font_size=24, background_color=[0, 0.6, 0, 1], background_normal='', size_hint=(0.2, 1), on_release=self.restart) I1 = Image(source='E:\images\off2.png') but_off.add_widget(I1) b2.add_widget(but_off) self.titl = Button(text='Индикация параметров', halign='left', bold=True, font_size=24, background_color=[0, 0.6, 0, 1], background_normal='', background_down='') b2.add_widget(self.titl) but_set = Button(on_release=self.rebuild_set, font_size=24, background_color=[0, 0.6, 0, 1], background_normal='', size_hint=(0.2, 1)) I2 = Image(source='E:\images\set2.png') but_set.add_widget(I2) b2.add_widget(but_set) self.list_button = self.list_but self.list_adapter = ListAdapter(data=[], cls=self.list_button, allow_empty_selection=False) self.list_view = ListView(adapter=self.list_adapter) self.list_button.background_color = [1, 1, 1, 1] self.list_button.background_normal = '' self.list_button.on_release = self.show_popup self.list_view.container.spacing = 10 self.list_button.font_size = 24 self.list_button.font_name = 'arialbd' self.list_button.bold = True self.list_button.color = [0, 0, 0, 1] self.list_button.padding = 30 self.list_button.halign = 'left' self.list_button.text_size = (Window.width, 0) self.list_adapter.data = [] I1.x = 0 - I2.width * 0.125 I1.y = Window.height - I2.height * 0.9 I2.x = Window.width - I2.width * 0.9 I2.y = Window.height - I2.height * 0.9 self.root.add_widget(b2) self.root.add_widget(self.list_view) self.but_0x = Button(on_release=self.do_set, text='0x', bold=True, font_size=28, background_color=[0, 0.6, 0, 1], background_normal='') self.but_1x = Button(on_release=self.di_set, text='1x', bold=True, font_size=28, background_color=[0, 0.6, 0, 1], background_normal='') self.but_3x = Button(on_release=self.ai_set, text='3x', bold=True, font_size=28, background_color=[0, 0.6, 0, 1], background_normal='') self.but_4x = Button(on_release=self.hr_set, text='4x', bold=True, font_size=28, background_color=[0, 0.6, 0, 1], background_normal='') b3.add_widget(self.but_0x) b3.add_widget(self.but_1x) b3.add_widget(self.but_3x) b3.add_widget(self.but_4x) self.root.add_widget(b3) self.hr_set() Clock.schedule_interval(self.update, 1)
def rebuild_set(self, instance): try: self.clear_all() global do_par, di_par, ai_par, hr_par, send_info b2 = BoxLayout(orientation='vertical') b3 = BoxLayout(orientation='horizontal', size_hint=(1, 0.08)) g1 = GridLayout(cols=2, spacing=30, padding=25, size_hint=(1, .175)) g2 = GridLayout(cols=2, spacing=30, padding=25, size_hint=(1, .175)) g3 = GridLayout(cols=2, spacing=30, padding=25, size_hint=(1, .175)) g4 = GridLayout(cols=2, spacing=30, padding=25, size_hint=(1, .175)) g1.add_widget( Label(text='Количество', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.do_num = (TextInput(text=do_par.split(', ')[2], multiline=False, font_size=20)) g1.add_widget(self.do_num) g1.add_widget( Label(text='Адрес', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.do_adr = (TextInput(text=do_par.split(', ')[1], multiline=False, font_size=20)) g1.add_widget(self.do_adr) g2.add_widget( Label(text='Количество', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.di_num = (TextInput(text=di_par.split(', ')[2], multiline=False, font_size=20)) g2.add_widget(self.di_num) g2.add_widget( Label(text='Адрес', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.di_adr = (TextInput(text=di_par.split(', ')[1], multiline=False, font_size=20)) g2.add_widget(self.di_adr) g3.add_widget( Label(text='Количество', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.ai_num = (TextInput(text=ai_par.split(', ')[2], multiline=False, font_size=20)) g3.add_widget(self.ai_num) g3.add_widget( Label(text='Адрес', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.ai_adr = (TextInput(text=ai_par.split(', ')[1], multiline=False, font_size=20)) g3.add_widget(self.ai_adr) g4.add_widget( Label(text='Количество', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.hr_num = (TextInput(text=hr_par.split(', ')[2], multiline=False, font_size=20)) g4.add_widget(self.hr_num) g4.add_widget( Label(text='Адрес', font_size=20, halign='left', size_hint=(.2, .1), color=[0, 0, 0, 1])) self.hr_adr = (TextInput(text=hr_par.split(', ')[1], multiline=False, font_size=20)) g4.add_widget(self.hr_adr) but_back = Button(on_release=self.save_set, font_size=24, background_color=[0, 0.6, 0, 1], background_normal='', size_hint=(0.2, 1)) I1 = Image(source='E:\images\menu2.png') but_back.add_widget(I1) b3.add_widget(but_back) b3.add_widget( Button(text='Настройки', bold=True, font_size=28, background_color=[0, 0.6, 0, 1], background_normal='', background_down='')) b3.add_widget( Button(font_size=28, background_color=[0, 0.6, 0, 1], background_normal='', background_down='', size_hint=(0.2, 1))) b2.add_widget(b3) b2.add_widget( Label(text='Цифровые выходы:', font_size=24, halign='center', size_hint=(1, 0.05), color=[0, 0, 0, 1])) b2.add_widget(g1) b2.add_widget( Label(text='Цифровые входы:', font_size=24, halign='center', size_hint=(1, 0.05), color=[0, 0, 0, 1])) b2.add_widget(g2) b2.add_widget( Label(text='Аналоговые входы:', font_size=24, halign='center', size_hint=(1, 0.05), color=[0, 0, 0, 1])) b2.add_widget(g3) b2.add_widget( Label(text='Регистры временного хранения информации:', font_size=24, halign='center', size_hint=(1, 0.05), color=[0, 0, 0, 1])) b2.add_widget(g4) I1.x = 0 - I1.width * 0.125 I1.y = Window.height - I1.height * 0.9 self.root.add_widget(b2) finally: pass