def create_main_screen(self): main_screen = BoxLayout() ## buttons button_layout = BoxLayout(orientation='vertical') xtabs_btn = Button(text="Crosstab Reports", size_hint=(.5,.3), on_press = self.main_to_xtabs) xtabs_btn.font_name = "Y2" top_btn = Button(text="Topline Reports", size_hint=(.5,.3), on_press = self.main_to_top) top_btn.font_name = "Y2" rnc_btn = Button(text="RNC Reports", size_hint=(.5,.3), on_press = self.main_to_rnc) rnc_btn.font_name = "Y2" help_btn = Button(text="Help", size_hint=(.5,.15), on_press = self.main_help) help_btn.font_name = "Y2" help_btn.background_normal = '' help_btn.background_color = (0.07, 0.306, 0.651, 1) button_layout.add_widget(xtabs_btn) button_layout.add_widget(top_btn) button_layout.add_widget(rnc_btn) button_layout.add_widget(help_btn) main_screen.add_widget(button_layout) # y2 logo screen_image = Image() screen_image.source = "resources/images/y2_white_logo.png" main_screen.add_widget(screen_image) return main_screen
def _draw_hearts(self): self.clear_widgets() i = 0 while i < (self.max_health / 4): heart = Image(size=(80, 80)) heart.source = 'img/heart-' + str(self.hearts[i]) + '.png' self.add_widget(heart) i += 1
def IMAG(self): layout = RelativeLayout() widget3 = Widget() img2 = Image() img2.source = "img/text.png" x, y = 130, 370 img2.pos = x + self.xo, y - 420 + self.yo img2.size = 300, 680 widget3.add_widget(img2) self.widget1.add_widget(widget3)
def showPicture(self, *args): self.clear_widgets() i1 = Image() i1.keep_ratio = True i1.source = 'simplekivy3.gif' self.add_widget(i1) b1 = Button() b1.size_hint_y = 0.1 b1.background_color = (1, 0, 0, 1) b1.text = '< -- Back' self.add_widget(b1) b1.bind(on_press=self.showMenu)
def IMAG2(self): layout = RelativeLayout() widget4 = Widget() img2 = Image() img2.source = "img/text.png" x, y = 140, -250 img2.pos = x, y img2.size = 300, 680 widget4.add_widget(img2) layout.add_widget(widget4) self.widget1.add_widget(layout)
def __init__(self, display): self.board = [[] for x in xrange(15)] self.seed_ref = [] for index in range(6 * 12): seed = Image() seed.id = "seed,{}".format(index) seed_pic = random.choice( SEED_DICT[settings['seed_choice']]['images']) seed.source = seed_pic['file'] seed.pos_fixed = (2000, 2000) seed.spot_fixed = seed_pic['true_spot'] seed.size_fixed = seed_pic['size_fixed'] display.game_screen_root.add_widget(seed) self.board[HAND].append(seed) self.seed_ref.append(seed) hand = Image() hand.id = "user_hand" hand.source = img_dir + "/user-hand-01.png" hand.pos_fixed = GameScreen.HANDS[USER]['pos'] hand.spot_fixed = (300, 1500 - 128) hand.size_fixed = (600, 1500) display.game_screen_root.add_widget(hand) self.user_hand = hand hand = Image() hand.id = "ai_hand" hand.source = img_dir + "/ai-hand-01.png" hand.pos_fixed = GameScreen.HANDS[AI]['pos'] hand.spot_fixed = (340, 128) hand.size_fixed = (600, 1500) display.game_screen_root.add_widget(hand) self.ai_hand = hand face = Image() face.id = "ai_picture" face.source = img_dir + "/ai-pic-01.png" face.pos_fixed = (-1000, 2401) face.size_fixed = (300, 300) self.ai_face = face display.game_screen_root.add_widget(face) self.display = display
def Label2(self): widget3 = Widget() img2 = Image() img2.source = "img/text.png" x, y = 130, 370 img2.pos = x + self.xo, y - 160 + self.yo img2.size = 300, 500 lbl2 = Label() lbl2.pos = x + 90 + self.xo, y + 40 + self.yo lbl2.text = " " + 'HACK-VISION DEMO\n Recibe GPS \n' + " " + ' Blueetooth ' widget3.add_widget(img2) widget3.add_widget(lbl2) self.widget1.add_widget(widget3)
def Label2(self): widget3 = Widget() img2 = Image() img2.source = "img/text.png" x, y = 130, 370 img2.pos = x + self.xo, y - 160 + self.yo img2.size = 300, 500 lbl2 = Label() lbl2.pos = x + 90 + self.xo, y + 40 + self.yo lbl2.text = " " + 'HACK-VISION DEMO\n CLIENTE BLUETOOTH ENVIO\n' + " " + ' GPS' widget3.add_widget(img2) widget3.add_widget(lbl2) self.widget1.add_widget(widget3)
def Label2(self): widget3 = Widget() img2 = Image() img2.source = "img/text.png" x, y = 50, 330 img2.pos = x, y - 160 img2.size = 300, 500 lbl2 = Label() lbl2.pos = x + 90, y + 40 lbl2.font_size = '18dp' lbl2.text = " " + 'FReePS DEMO\n Diego Alberto Parra \n' + " " + ' Bogota D.C.' widget3.add_widget(img2) widget3.add_widget(lbl2) Mprincipal.add_widget(widget3)
def Animacion1(self, *args): global Anim lol = Widget() Anim = Image() Anim.source = "img/fondo_brujula.png" # Anim.size = 700,700 #Anim.source = "img/caballo.zip" #Anim.anim_delay=(0.15) # Anim.pos_hint= {"x": -0.1, "center_y": -1} # Anim.pos = 10, 10 #Anim.pos = random.randrange(100,680), random.randrange(100,460) self.dis1.add_widget(Anim) lol.add_widget(self.dis1) self.widget1.add_widget(lol)
def iniciar(self, tipo='blocos', *args): # Limpando área responsável pelos blocos self.ids.blocos_memoria.clear_widgets() # Se "tipo" for "blocos", irá iniciar o jogo em si if (tipo == 'blocos'): ######################### INFO ######################### # Para evitar problemas no "Thread" para carregar e # # exibir as Imagens, elas e os Botões (BotaoSecreto) # # são criados anteriormente para depois serem passados # # como argumento no método "gerar_blocos" # ######################################################## # Lista para armazenar os Widgets criados imagens = [] botoes = [] # Para cada item em jome.memoria for i in range(len(self.jome.memoria)): # Criando Widget de Imagem img = Image() # Passando Imagem que será utilizada com base no # index armazenado em jome.memoria[i] img.source = self.jome.imagens[self.jome.memoria[i]] # Adicionando à lista imagens.append(img) # Gerando Botão (BotaoSecreto) bts = BotaoSecreto() # Armazenando o id (index) da Imagem que ele representa bts.id_img = self.jome.memoria[i] # Adicionando função que será executada quando ele terminar # de ser clicado, e passando a tela atual (TelaJogo) como # argumento através do "self" bts.bind(on_release=partial(bts.clicado, self)) # Adicionando à lista botoes.append(bts) # Iniciando Thread do método "gerar_blocos" threading.Thread(target=self.gerar_blocos, args=(imagens, botoes)).start() # Se "tipo" for "tela_espera", irá exibir a tela de espera antes de iniciar elif (tipo == 'tela_espera'): # Iniciando Thread do método "gerar_tela_espera" threading.Thread(target=self.gerar_tela_espera).start()
def Label1(self): global lbl1 img2 = Image() img2.source = "img/text.png" # img2.pos = 215, 140 img2.pos = 400, 160 img2.size = 400, 500 lbl1 = Label() lbl1.text = "Esperando instrucciones:" # lbl1.pos = 200,140 lbl1.pos = 530, 380 lbl1.font_size = "14dp" Mprincipal.add_widget(img2) Mprincipal.add_widget(lbl1) print "Esperando instrucciones:"
def back_to(self): # Restores the home screen self.lay_center.clear_widgets() self.clear_widgets() self.lay_center_bt.clear_widgets() image_back_ground = Image() image_back_ground.source = 'image/background_ppmt_main.png' button_new_open_close = ButtonNewOpen(new_proj=self.new_project, open_proj=self.open_project) self.add_widget(image_back_ground) self.lay_center_bt.add_widget(button_new_open_close) self.lay_center.add_widget(self.lay_center_bt) self.lay_center.add_widget(self.lay_last_project) self.add_widget(self.lay_center)
def back_to(self): # Restores the home screen self.lay_center.clear_widgets() self.clear_widgets() self.lay_center_bt.clear_widgets() image_back_ground = Image() image_back_ground.source = 'image/background_ppmt_main.png' button_new_open_close = ButtonNewOpen(new_proj=self.new_project, open_proj=self.open_project) self.add_widget(image_back_ground) self.lay_center_bt.add_widget(button_new_open_close) self.lay_center.add_widget(self.lay_center_bt) self.lay_center.add_widget(self.lay_last_project) self.add_widget(self.lay_center)
def update(self, *args): dateLabel = self.ids['DateLabel'] dateLabel.text = time.strftime("%A %B %d %Y") timeLabel = self.ids['TimeLabel'] timeLabel.text = time.strftime("%I:%M:%S %p") if self.manager.AlarmService: alarmOnButton = self.ids['alarmOn_button'] if self.manager.AlarmService.AlarmOn == True: if self.alarmShowing == False: self.alarmShowing = True alarmImage = Image() alarmImage.source = 'trans-alarmclock.png' alarmOnButton.add_widget(alarmImage) else: alarmOnButton.clear_widgets() self.alarmShowing = False
def __init__(self, **kwargs): # accesses properties and methods from FloatLayout super().__init__(**kwargs) global bestPopCount, store # create a cloud layout layer where all the clouds will be spawned (this will be above the sky background) cloud_layout = CloudLayout() self.add_widget(cloud_layout) # in the json file set as store in global variables, get the best score value saved to local memory in at the # key 'bestScore' bestPopCount = store.get('bestScore')['best'] # create a new float layout for menu items self.menu_layout = FloatLayout() # create the start button start_button = Button() # the start button width and height should both take up 30% of the screen start_button.size_hint = (.3, .3) # the start button should be located in the middle of the screen horizontally and 30% up the screen vertically start_button.pos_hint = {'center_x': .5, 'center_y': .3} # set the start button text to say "start" start_button.text = "Start" # change its font style start_button.font_name = "PressStart2P.ttf" # make the font medium sized start_button.font_size = "20sp" # upon the buttons release it will remove the layout with all menu items attached to it start_button.bind(on_release=self.remove_layout) # creates an image object for the title image title = Image() # the image should take up no more than 90% of the screen horizontally and no more than 90% of screen vertically title.size_hint = (.9, .9) # the title image is centered horizontally and located 70% up screen vertically title.pos_hint = {'center_x': .5, 'center_y': .7} # changes the title image to the title image .png file title.source = "Assets/popper_pig_title.png" # add the start button and the title to the menu layout self.menu_layout.add_widget(start_button) self.menu_layout.add_widget(title) # add the menu layout self.add_widget(self.menu_layout)
def __init__(self, **kwargs): super(GameWindow, self).__init__(**kwargs) self.cols=1 self.rows=2 self.GameWindow1=GridLayout() self.GameWindow1.cols=1 self.GameWindow1.rows=3 self.GameWindow1.add_widget(Label(text="COMPUTER DEALER", font_size=20, color = (0,1,1,1), halign = "center", valign = "center")) self.GameWindow2=GridLayout() self.GameWindow2.cols=7 self.GameWindow2.rows=1 self.GameWindow2.add_widget(Label(text="")) compCardImage1=Image(source=imagePath + "blue_back.png") self.GameWindow2.add_widget(compCardImage1) compCardImage2=Image(source=imagePath + "blue_back.png") self.GameWindow2.add_widget(compCardImage2) compCardImage3=Image(source=imagePath + "blue_back.png") self.GameWindow2.add_widget(compCardImage3) compCardImage4=Image(source=imagePath + "blue_back.png") self.GameWindow2.add_widget(compCardImage4) compCardImage5=Image(source=imagePath + "blue_back.png") self.GameWindow2.add_widget(compCardImage5) self.GameWindow2.add_widget(Label(text="")) self.GameWindow3=GridLayout() self.GameWindow3.cols=1 self.GameWindow3.rows=1 self.GameWindow4=GridLayout() self.GameWindow4.cols=1 self.GameWindow4.rows=3 self.GameWindow5=GridLayout() self.GameWindow5.cols=7 self.GameWindow5.rows=1 self.GameWindow5.add_widget(Label(text="")) playerCardImage1=Image(source=imagePath + "blue_back.png") self.GameWindow5.add_widget(playerCardImage1) playerCardImage2=Image(source=imagePath + "blue_back.png") self.GameWindow5.add_widget(playerCardImage2) playerCardImage3=Image(source=imagePath + "blue_back.png") self.GameWindow5.add_widget(playerCardImage3) playerCardImage4=Image(source=imagePath + "blue_back.png") self.GameWindow5.add_widget(playerCardImage4) playerCardImage5=Image(source=imagePath + "blue_back.png") self.GameWindow5.add_widget(playerCardImage5) self.GameWindow5.add_widget(Label(text="")) self.GameWindow6=GridLayout() self.GameWindow6.cols=1 self.GameWindow6.rows=1 self.GameWindow6.add_widget(Label(text="PLAYER", font_size=20, color=(0,1,1,1), halign="center", valign="center")) self.GameWindow7=GridLayout() self.GameWindow7.cols=7 self.GameWindow7.rows=1 self.GameWindow7.add_widget(Label(text="")) self.GameWindow7.add_widget(Label(text="")) self.hitButton=Button(text="HIT", font_size=20, background_color=(0,1,1,1)) self.GameWindow7.add_widget(self.hitButton) self.GameWindow7.add_widget(Label(text="")) self.stayButton=Button(text="STAY", font_size=20, background_color=(0,1,1,1)) self.GameWindow7.add_widget(self.stayButton) self.GameWindow7.add_widget(Label(text="")) self.GameWindow7.add_widget(Label(text="")) self.add_widget(self.GameWindow1) self.GameWindow1.add_widget(self.GameWindow2) self.GameWindow1.add_widget(self.GameWindow3) self.add_widget(self.GameWindow4) self.GameWindow4.add_widget(self.GameWindow5) self.GameWindow4.add_widget(self.GameWindow6) self.GameWindow4.add_widget(self.GameWindow7) deck = Deck() deck.shuffle() playerCoins = Coins() playing=True playerHandList = [] compHandList = [] #creating starting status of game playerHand = Hand() playerHand.addCard(deck.deal()) playerHand.addCard(deck.deal()) compHand = Hand() compHand.addCard(deck.deal()) compHand.addCard(deck.deal()) #appending starting cards into respective lists for i in playerHand.cards: playerHandList.append(str(i)) for i in compHand.cards: compHandList.append(str(i)) #displaying starting cards in gui playerCardImage1.source = imagePath + playerHandList[0] playerCardImage2.source = imagePath + playerHandList[1] compCardImage1.source = imagePath + compHandList[0] def hit(instance): playerHand.addCard(deck.deal()) #new card added in player's hand object (background) for i in playerHand.cards: if str(i) not in playerHandList: playerHandList.append(str(i)) #append newly added card in player hand list playerHand.adjustForAce() #adding new cards in gui print(playerHandList) if len(playerHandList) == 3: playerCardImage3.source = imagePath + playerHandList[2] #3rd card showed elif len(playerHandList) == 4: playerCardImage4.source = imagePath + playerHandList[3] #4th card showed elif len(playerHandList) == 5: playerCardImage4.source = imagePath + playerHandList[4] #5th card showed #checking if player busts or not if playerHand.value > 21: ''' write bust code here ''' print("player bust!") screen_manager.current = "Bet" #binding buttons with functions self.hitButton.bind(on_press=hit)
def build(self,nom,prenom,nuance,sortant,personalite,dico_envoi,dico_score,dico_scrutin_nuance_proba,liste_oui,liste_petit_effectif): global compteur #Pour pouvoir faire les explications on a besoin de stoquer dans la classe les données self.nom = nom self.liste_oui = liste_oui self.liste_petit_effectif = liste_petit_effectif self.prenom = prenom self.nuance = nuance self.sortant = sortant self.dico_envoi = dico_envoi if self.sortant: """ sql_command = "SELECT uid FROM Elu WHERE nom = '{}' AND prenom = '{}'".format(self.nom,self.prenom) cursor.execute(sql_command) for item in cursor: uid_elu = item[0] self.score_affinité,self.dico_vote_elu = make_score_sortant(uid_elu,self.dico_envoi) """ pass else: pass self.score_affinite = dico_score[self.nuance] self.score_affinite = dico_score[self.nuance] #print(self.liste_oui) self.dico_candidat = 0 self.dico_scrutin_nuance_proba = dico_scrutin_nuance_proba self.personalite = personalite self.cols = 1 #print(self.score_affinite) self.dico_texte_reponse = {} self.dico_texte_question = {} self.dico_nuance_nom = {"EXG" : "d'Extrême Gauche","PG":"du Parti de Gauche","COM":"Communistes", "SOC":"Socialistes","RDG":"Radicaux de Gauche","DVG":"Divers Gauche", "ECO":"Ecologistes","REG":"Regionalistes","DIV":"Divers","MDM":"Modem", "REM":"Républiques en Marche","UDI":"Union des démocrates et indépendants", "LR":"Républicains","DVD":"Divers Droite","DLF":"Debout la France", "FN":"Front National","EXD":"Extrême droite","FI":"France Insoumise"} self.resultat_IA = "Oui" * (self.nuance in self.liste_oui) + "Non" * (self.nuance not in self.liste_oui) if self.nuance in self.liste_oui: self.resultat_IA = "Oui" elif self.nuance in self.liste_petit_effectif or self.score_affinite == -10: self.resultat_IA = "???" else: self.resultat_IA = "Non" for reponse in os.listdir("Texte_bouton"): with open(os.path.join("Texte_bouton",reponse)) as file: self.dico_texte_reponse[reponse] = file.read() #(file.read()) for question in os.listdir("Questions"): # question est l'uid du scrutin path_question = os.path.join("Texte_résumé",question) with open(path_question,"r") as file: texte_question = file.read() self.dico_texte_question[question] = texte_question """ for reponse in os.listdir("Texte_bouton"): with codecs.open(os.path.join("Texte_bouton",reponse), "r", encoding='utf-8') as file: self.dico_texte_reponse[reponse] = file.read() for question in os.listdir("Questions"): # question est l'uid du scrutin path_question = os.path.join("Questions",question) with codecs.open(path_question, "r", encoding='utf-8') as file: texte_question = file.read() self.dico_texte_question[question] = texte_question """ #Layout de la bande du haut layout_haut = BoxLayout(orientation = "horizontal") #de gauche à droite photo Nom Nuance avec logo ou de couleur (a priori label coloré) photo_candidat = Image() photo_candidat.source = "images_candidat/{}.jpg".format(compteur) compteur+=1 layout_haut.add_widget(photo_candidat) #label_nom = Label(text = (prenom + " " + nom)) label_nom = WrappedLabel(text = (prenom + " " + nom)) label_nom.halign = "left" label_nom.font_size = 30 layout_haut.add_widget(label_nom) image_nuance = Image(source = "image_nuance/"+self.nuance+".png") layout_haut.add_widget(image_nuance) layout_haut.size_hint_y = 0.2 #Layout de la bande centrale avec les résultats layout_score = BoxLayout(orientation = "horizontal") layout_score.size_hint_y = 0.6 #sous-Layout pour le score d'affinité layout_score_affinité = BoxLayout(orientation = "vertical") label_affinite = Label(text = "Score d'Affinité") label_affinite.size_hint_y = 0.3 label_affinite.font_size = 40 layout_score_affinité.add_widget(label_affinite) string_label_score = (dico_score[self.nuance] != -10)*(str(dico_score[self.nuance])+"/100") + "???"*(dico_score[self.nuance] == -10) label_score_affinite = Label(text = string_label_score) label_score_affinite.font_size = 100 label_score_affinite.size_hint_y = 0.7 layout_score_affinité.add_widget(label_score_affinite) #sous-Layout pour le resultat IA layout_resultat_IA = BoxLayout(orientation = "vertical") label_IA = Label(text = "Conseil IA") label_IA.font_size = 40 label_IA.size_hint_y = 0.3 layout_resultat_IA.add_widget(label_IA) label_resultat_IA = Label(text = str(self.resultat_IA)) label_resultat_IA.font_size = 100 label_resultat_IA.size_hint_y = 0.7 layout_resultat_IA.add_widget(label_resultat_IA) #Ajout des layout score et IA au layout central score layout_score.add_widget(layout_score_affinité) layout_score.add_widget(layout_resultat_IA) self.layout_bouton_explication = GridLayout(cols = 5) self.layout_bouton_explication.size_hint_y = 0.2 self.bouton_explication = Button(text = "Explications") self.bouton_explication.bind(on_press = self.explication) self.bouton_explication.id = self.nuance + "," + self.sortant self.layout_bouton_explication.add_widget(self.bouton_explication) self.add_widget(layout_haut) self.add_widget(layout_score) self.add_widget(self.layout_bouton_explication)
def __init__(self, ms, **kwargs): super(MasterClient.Home, self).__init__(**kwargs) self.ms = ms # Float Layout Top Bar self.float_layout = FloatLayout() self.float_layout.size_hint = (None, None) # self.float_layout.pos_hint = (None, None) # Não pode definir no FloatLayout self.float_layout.size = (402, 85) self.float_layout.y = 630 # Top Bar image self.top_bar = Image() self.float_layout.add_widget(self.top_bar) self.top_bar.source = ("interface/Home/top_bar1.png") self.top_bar.y = 630 # AddContact button self.add_contact_btn = Button() self.float_layout.add_widget(self.add_contact_btn) self.add_contact_btn.size_hint = (None, None) self.add_contact_btn.size = (40, 40) self.add_contact_btn.pos = (345, 643) self.add_contact_btn.background_color = (1.0, 1.0, 1.0, 0) self.add_contact_btn.on_press = self.press_add_contact_button # Switch status button self.switch_status = Button() self.float_layout.add_widget(self.switch_status) self.switch_status.size_hint = (None, None) self.switch_status.size = (43, 24) self.switch_status.pos = (20, 651) self.switch_status.background_color = (1.0, 1.0, 1.0, 0) self.switch_status.on_press = self.press_switch_status # Switch status image self.switch_img = Image() self.add_widget(self.float_layout) self.switch_status.add_widget(self.switch_img) self.switch_img.source = ("interface/Home/switch_on.png") self.switch_img.size = (43, 24) self.switch_img.pos = (20, 651) # Scroll View self.scroll_view = ScrollView() self.add_widget(self.scroll_view) self.scroll_view.size_hint = (None, None) self.scroll_view.size = (402, 630) self.scroll_view.y = self.scroll_view.parent.x self.scroll_view.orientation = "vertical" self.scroll_view.background_color = (255, 0, 0, 1) # Box View chats self.box = BoxLayout() self.scroll_view.add_widget(self.box) self.box.id = "box" self.box.orientation = "vertical" self.box.size_hint_y = None self.box.bind(minimum_height=self.box.setter("height")) self.box.y = self.box.parent.y print(len(contacts)) for contact in contacts: print("entrei aqui no coisa do bicho do negoço") print(contact) ### # Box button box_button = Button() self.box.add_widget(box_button) box_button.size_hint = (None, None) box_button.width = 402 box_button.height = 80 #box_button.background_color = (255, 255, 255, 1) # Contact photo image contact_photo = Image() box_button.add_widget(contact_photo) contact_photo.source = ("interface/Home/contact.png") contact_photo.size_hint = (None, None) contact_photo.pos_hint = (None, None) contact_photo.size = (80, 80) contact_photo.pos = (0, 0) # Contact status img contact_img_status = Image() box_button.add_widget(contact_img_status) contact_img_status.source = ("interface/online.png") contact_img_status.size_hint = (None, None) contact_img_status.pos_hint = (None, None) contact_img_status.size = (80, 80) contact_img_status.pos = (330, contact_img_status.parent.y) # Contact name label lbl_name = Label() box_button.add_widget(lbl_name) lbl_name.text = contact_name lbl_name.size = (15, 120) lbl_name.pos = (90, contact_img_status.parent.y)