How to use create_label method in autotest

Best Python code snippet using autotest_python

main.py

Source:main.py Github

copy

Full Screen

1from tkinter import *2from tkinter import messagebox3import requests4def create_label(text, font, bg, row, column, columnspan=1, sticky=''):5 elem = Label(window, text=text, font=font, bg=bg, padx=20)6 elem.grid(row=row, column=column, columnspan=columnspan, sticky=sticky)7 return elem8def start_change():9 try:10 input_value = float(input_forValue.get())11 input_forValueUSD.delete(0, END)12 input_forValueUSD.insert(0, round(input_value * float(label_usd_buy['text']), 2))13 input_forValueEUR.delete(0, END)14 input_forValueEUR.insert(0, round(input_value * float(label_eur_buy['text']), 2))15 input_forValueUAN.delete(0, END)16 input_forValueUAN.insert(0, round(input_value * float(label_uan_buy['text']), 2))17 except:18 messagebox.showerror(title='Ошибка обмена', message='Проверьте правильность ввода данных')19URL_ADRESS = 'https://www.cbr-xml-daily.ru/latest.js'20response = requests.get(URL_ADRESS)21JSON = response.json()22window = Tk()23window.title('Конвертер валют')24window.geometry('335x250+300+300')25window.resizable(0, 0)26create_label('Валюта', 'Arial 12 bold', '#d9cece', 0, 0)27create_label('Покупка', 'Arial 12 bold', '#d9cece', 0, 1)28create_label('Продажа', 'Arial 12 bold', '#d9cece', 0, 2)29create_label('USD', 'Arial 11', '#f7dfdf', 1, 0, 1, EW)30label_usd_buy = create_label(JSON['rates']['USD'], 'Arial 11', '#f7dfdf', 1, 1, 1, EW)31label_usd_sale = create_label(round(JSON['rates']['USD'] - (JSON['rates']['USD'] * 1.5 / 100), 6), 'Arial 11', '#f7dfdf', 1, 2, 1, EW)32create_label('EUR', 'Arial 11', '#d9cece', 2, 0, 1, EW)33label_eur_buy = create_label(JSON['rates']['EUR'], 'Arial 11', '#d9cece', 2, 1, 1, EW)34label_eur_sale = create_label(round(JSON['rates']['EUR'] - (JSON['rates']['EUR'] * 1.5 / 100), 6), 'Arial 11', '#d9cece', 2, 2, 1, EW)35create_label('UAN', 'Arial 11', '#f7dfdf', 3, 0, 1, EW)36label_uan_buy = create_label(JSON['rates']['UAH'], 'Arial 11', '#f7dfdf', 3, 1, 1, EW)37label_uan_sale = create_label(round(JSON['rates']['UAH'] - (JSON['rates']['UAH'] * 1.5 / 100), 6), 'Arial 11', '#f7dfdf', 3, 2, 1, EW)38current_valute = Label(window, text='Рубль:', font='Arial 11 bold', pady=5)39current_valute.grid(row=4, column=0, columnspan=1, sticky=EW)40input_forValue = Entry(window, justify=CENTER)41input_forValue.grid(row=4, column=1, columnspan=2, sticky=EW)42button_change = Button(window, text='Обмен', font='Arial 12 bold', command=start_change)43button_change.grid(row=5, column=1, columnspan=2, sticky=EW)44current_usd = Label(window, text='USD:', font='Arial 11 bold', pady=1)45current_usd.grid(row=7, column=0, columnspan=1, sticky=EW)46input_forValueUSD = Entry(window, justify=CENTER)47input_forValueUSD.grid(row=7, column=1, columnspan=2, sticky=EW)48current_eur = Label(window, text='EUR:', font='Arial 11 bold', pady=1)49current_eur.grid(row=8, column=0, columnspan=1, sticky=EW)50input_forValueEUR = Entry(window, justify=CENTER)51input_forValueEUR.grid(row=8, column=1, columnspan=2, sticky=EW)...

Full Screen

Full Screen

info.py

Source:info.py Github

copy

Full Screen

...1920 def create_state_labels(self):21 self.state_labels = []22 if self.state == 'menu':23 self.state_labels.append((self.create_label('1 PLAYER GAME'), (272, 360)))24 self.state_labels.append((self.create_label('2 PLAYER GAME'), (272, 405)))25 self.state_labels.append((self.create_label('TOP: '), (290, 465)))26 self.state_labels.append((self.create_label('000000'), (360, 465)))27 elif self.state == 'load':28 self.state_labels.append((self.create_label('WORLD'), (280, 200)))29 self.state_labels.append((self.create_label('1 - 1'), (430, 200)))30 self.state_labels.append((self.create_label('X : {}'.format(self.game_info['lives'])), (380, 280)))31 self.player_image = Tools.get_image(setup.PICTURE['mario_bros'],178, 32, 12, 16, (0,0,0), C.BG_MULTI)32 elif self.state == 'game_over':33 self.state_labels.append((self.create_label('Game Over'), (280, 300)))34 elif self.state == 'success':35 self.state_labels.append((self.create_label('Second Pass'), (280, 300)))363738 def create_info_labels(self):39 self.info_labels = []40 self.info_labels.append((self.create_label('MARIO'), (75, 30)))41 self.info_labels.append((self.create_label('WORLD'), (450, 30)))42 self.info_labels.append((self.create_label('TIME'), (625, 30)))43 self.info_labels.append((self.create_label('000000'), (75, 55)))44 self.info_labels.append((self.create_label('x00'), (300, 55)))45 self.info_labels.append((self.create_label('1 - 1'), (480, 55)))464748 def create_label(self, label, size = 20, width_scale = 1.25, height_scale = 1):49 font = pygame.font.SysFont(C.FONT, size)50 label_image = font.render(label, 1, (255,255,255))51 rect = label_image.get_rect()52 label_image = pygame.transform.scale(label_image, (int(rect.width * width_scale),53 int(rect.height * width_scale)))54 return label_image5556 def update(self):57 self.flash_coin.update()5859 def draw(self, surface):60 # surface.blit(self.create_label('ISSAC AND THOR!', size=60), (100,400))61 for label in self.state_labels:62 surface.blit(label[0], label[1])63 for label in self.info_labels:64 surface.blit(label[0], label[1])65 surface.blit(self.flash_coin.image, self.flash_coin.rect)6667 if self.state == 'load': ...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful