def test_title_font_family(web_driver): """ Check if the font family of the block content is 'sans-serif' """ homepage = MainPage(web_driver) rules_pages = homepage.click_to_rules_topmenu_item(web_driver) assert rules_pages.title_font_family( web_driver ) == 'Segoe, Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif'
def test_validation_message_caused_by_sending_empty_field(web_driver): """Check if the validation message 'Поле обов'зкове для заповнення' has correct function with empty input field""" homepage = MainPage(web_driver) loginpage = homepage.click_to_login_button(web_driver) loginpage.login_with_empty_fieldweb_driver validation_message_text = loginpage.validation_message(web_driver) assert validation_message_text == 'Поле обов\'зкове для заповнення'
def test_voting_if_user_is_unlogined(web_driver): """ Checks if the voting by unlogined user is impossible """ homepage = MainPage(web_driver) vote_page = homepage.click_voting_button(web_driver) login_page = vote_page.choose_category('').with_subcategory( '').first_product(web_driver).click() assert "Вхід до голосування" in login_page(web_driver)
def test_click_on_mychoise_button_from_mainpage_logined(web_driver): """Check if the action of 'МІЙ ВИБІР' button is correct - logined user""" homepage = MainPage(web_driver) login_page = homepage.click_to_login_button(web_driver) my_choise_page = login_page.login_with_valid_card( web_driver, card_number='0291077164447') assert "Мій вибір" in my_choise_page.page_content(web_driver)
def test_checkDisplay(self): # Create instance of MainPage class main_page = MainPage(self.driver) # Call the required functions from MainPage main_page.headline_news_is_displayed() main_page.advert_is_displayed() main_page.planetf1_logo_is_displayed() main_page.social_media_is_displayed()
def test_error_message_does_not_exists_with_valid_card_number(web_driver): """Check if the validation message does not exists after entering the valid card number - 0291077164447""" homepage = MainPage(web_driver) loginpage = homepage.click_to_login_button(web_driver) loginpage.fill_the_card_number_field(driver=web_driver, card_number='0291077164447') error_message = loginpage.get_validation_message(web_driver) assert len(error_message) == 0
def test_validation_message_caused_by_invalid_card_number(web_driver): """Check if the validation message 'Невірний номер карти' has correct function with invalid card numder - 1111111111111""" homepage = MainPage(web_driver) loginpage = homepage.click_to_login_button(web_driver) loginpage.login_with_not_full_card_number(driver=web_driver, card_number='1111111111111') validation_text_message = loginpage.validation_message(web_driver) assert validation_text_message == 'Невірний номер карти'
def test_validation_message_caused_by_invalid_card_number_1_symbol(web_driver): """Check if the validation message 'Номер має містити 13 цифр' has correct function with invalid card numder - 0""" homepage = MainPage(web_driver) loginpage = homepage.click_to_login_button(web_driver) loginpage.login_with_not_full_card_number(driver=web_driver, card_number='0') validation_text_message = loginpage.get_validation_message(web_driver) assert validation_text_message.lower() == 'номер має містити 13 цифр'
def test_login_with_correct_card_number(web_driver): """Check if the loginisation has correct functioning with valid card numder (029 0226351066). Cardnumber contains one space""" homepage = MainPage(web_driver) loginpage = homepage.click_to_login_button(web_driver) my_choise_page = loginpage.login_with_valid_card( driver=web_driver, card_number='029 0226351066') search_word = 'Мій вибір' assert search_word in my_choise_page.page_content(web_driver)
def test_validation_message_caused_by_sending_short_card_number_5_symbols( web_driver): """Check if the validation message 'Номер має містити 13 цифр' has correct function with notfull card numder - 02910""" homepage = MainPage(web_driver) loginpage = homepage.click_to_login_button(web_driver) loginpage.login_with_not_full_card_number(driver=web_driver, card_number='02910') validation_text_message = loginpage.validation_message(web_driver) assert validation_text_message == 'Номер має містити 13 цифр'
class TestAddmember: def setup(self): self.main = MainPage() def teardown(self): self.main.end() def test_addmemeber(self): self.main.goto_maillist().goto_addmember().addmember()
def initModule(self): self.mainpage = MainPage(self) self.sidebar = SideBar(self) self.sidebar.hide() self.tray = TraySet(self) self.tray.show() self.about = AboutMemo() self.about.hide() self.setting = SettingBar(self) self.setting.hide() self.windowIcon = QtGui.QIcon(css.AppIconPath) self.setWindowIcon(self.windowIcon) self.grabKeyboard()
def Main(): """Set up the environment and run the main loop """ config = configparser.ConfigParser() config.read('MikroKam.ini') ws = root.winfo_screenwidth() hs = root.winfo_screenheight() root.title("MikroKam") root.geometry('%dx%d+%d+%d' % (int(config['app']['screen_width']), int(config['app']['screen_height']), 0, 0)) root.resizable(width=FALSE, height=FALSE) mainPage = Frame(root) mainPage.grid(row=0, column=0) mainPage.minsize = ws gui = MainPage(mainPage, config, root) root.protocol("WM_DELETE_WINDOW", gui.close) root.mainloop() print("we are done") config['app']['last_run'] = datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S") with open('MikroKam.ini', 'w') as configfile: config.write(configfile)
def loginCheck(self): ipaddr = self.ipaddr.get() name = self.username.get() secret = self.password.get() ipflag = self.chk_ip(ipaddr) if ipflag: if not name or not secret: self.cfg.logger.warning("用户名或密码为空") showinfo(title="Warning", message="用户名或密码为空") elif not subprocess.call(self.tool + " -H %s -U %s -P %s raw 6 1" % (ipaddr, name, secret)): self.ipmi = self.tool + " -H %s -U %s -P %s " % (ipaddr, name, secret) self.cfg.logger.info(self.ipmi) # try: cmd = self.ipmi + "fru list 0" self.cfg.logger.info(cmd) try: subpro = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = subpro.communicate() if not subpro.returncode: self.cfg.logger.info(stdout) self.page.destroy() if re.search("Product Extra", stdout.decode('utf-8')): self.extraflag = True else: self.extraflag = False else: self.cfg.logger.error(stderr) self.cfg.logger.error("Get fru fail") showwarning(message="Get fru fail!!") except Exception as e: showinfo(message=str(e)) else: print(self.extraflag) MainPage(self.root, self.cfg, self.ipmi, self.extraflag) else: showinfo(title="Warning", message="BMC over lan fail, Please check it!")
def login(self, user, password): from mainpage import MainPage from homepage import HomePage box = TextBox(self._browser, self._config.get_locator('username')) box.set_text(user) box.set_locator(self._config.get_locator('password')) box.set_text(password) elem = Element(self._browser, self._config.get_locator('submit')) elem.click() page = HomePage(self._browser, False) if not page.is_logged_in(): msg = "Login failed" box.set_locator(self._config.get_locator('err_msg')) if (box.exists()): msg = box.get_text() assert msg == '' return MainPage(self._browser, False)
def __init__(self): tk.Tk.__init__(self) # colours self.bg_colour = "#202020" self.playlist_bg_colour = "#151515" self.taskbar_bg_colour = "#333333" self.sb_bar_colour = "#505050" self.sb_selected_colour = "#656565" self.dark_white_colour = "#8a8a8a" # fonts self.header_font = "Arial 32 bold" self.normal_font = "Arial 15" # font for playlist names and songs self.song_font = "Arial 12 bold" # images # basic setup self.default_width = 1000 # calculate this? self.default_height = 750 # calculate this? self.title("alphatunes") self.geometry(f"{self.default_width}x{self.default_height}") self.resizable(0, 0) self.minsize(self.default_width, self.default_height) # view mode (current frame) # frames, make resizable container = tk.Frame(self) container.place(x=0, y=0, width=self.default_width, height=self.default_height) self.frames = {"MAIN": MainPage(container, self)} # call main frame self.frames["MAIN"].tkraise()
from mainpage import MainPage from mysql_commands import execute_cmd #Creating database and table try: execute_cmd('CREATE DATABASE school') #Creates database execute_cmd(""" CREATE TABLE student_data (id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, Name VARCHAR(256), Class VARCHAR(10), Phone VARCHAR(15), DOB DATE, DOA DATE) """, database='school') #Creates table except Exception as e: pass #__main__ win = MainPage() win.add_notebooks() win.mainpage.mainloop()
def goto_main(self): """ 进入首页 :return: """ return MainPage(self.driver)
def test_title_font_size(web_driver): """ Check if font size of the title of the content is 32px """ homepage = MainPage(web_driver) rules_pages = homepage.click_to_rules_topmenu_item(web_driver) assert rules_pages.title_font_size(web_driver) == '32px'
def __init__(self, driver): MainPage.__init__(self, driver)
class Window(QWidget): def __init__(self, data=None): super(Window, self).__init__() self.initData(data) self.initUi() self.initModule() self.setModule() #hide menu bar self.setWindowFlags(Qt.Qt.FramelessWindowHint) self.setAttribute(Qt.Qt.WA_TranslucentBackground) #button self.mainpage.homeBtn.clicked.connect(self.flexSideBar) self.sidebar.newBtn.clicked.connect(self.addMemo) self.sidebar.setBtn.clicked.connect(self.settingMemo) self.sidebar.aboutBtn.clicked.connect(self.aboutMemo) #data self.dataLoad() def initData(self, data): self.data = read(data) self.memoSettings = readMemoSettings(data) def initUi(self): self.setWindowTitle('Memo') self.setMinimumWidth(600) self.setMaximumWidth(600) self.layout = QHBoxLayout() self.layoutl = QVBoxLayout() self.layoutr = QVBoxLayout() #self.layout.setMargin(0) self.layout.setSpacing(0) def initModule(self): self.mainpage = MainPage(self) self.sidebar = SideBar(self) self.sidebar.hide() self.tray = TraySet(self) self.tray.show() self.about = AboutMemo() self.about.hide() self.setting = SettingBar(self) self.setting.hide() self.windowIcon = QtGui.QIcon(css.AppIconPath) self.setWindowIcon(self.windowIcon) self.grabKeyboard() def setModule(self): self.layoutl.addWidget(self.mainpage) self.layoutl.addWidget(self.sidebar) self.layoutl.addStretch(1) #set main layout self.layout.addLayout(self.layoutl) self.layout.addLayout(self.layoutr) self.setLayout(self.layout) def dataLoad(self): content = readMemoContent(self.data) settings = readMemoSettings(self.data) if self.data['memo_num'] > 0: for i in range(self.data['memo_num']): info = {} info.update(id=i + 1, content=content[i]) info.update(settings) self.loadMemo(info) def loadMemo(self, data): label = Memo(self, data) allCount = self.layoutr.count() if allCount == 0: self.layoutr.addWidget(label) else: self.layoutr.insertWidget(allCount + 1, label) def addMemo(self): list = self.data['memo_data'] numInfo = len(list) > 0 and list[-1]['id'] or 0 info = {} info.update(id=numInfo + 1) info.update(self.memoSettings) allCount = self.layoutr.count() label = Memo(self, info) if allCount == 0: self.layoutr.addWidget(label) else: self.layoutr.insertWidget(allCount + 1, label) memo_data = {} memo_data.update(id=numInfo + 1, content='It is empty!', set_date='', if_done={}) self.data['memo_data'].append(memo_data) self.data['memo_num'] = len(list) write(self.data) def aboutMemo(self): self.about.show() def settingMemo(self): self.setting.show() def getTrashPos(self): return self.mainpage.getTrashPos() def flexSideBar(self): if self.sidebar.isHidden(): self.sidebar.show() else: self.sidebar.hide() #move without form def mousePressEvent(self, QMouseEvent): if QMouseEvent.button() == Qt.Qt.LeftButton: self.flag = True self.m_Position = QMouseEvent.globalPos() - self.pos() QMouseEvent.accept() self.setCursor(Qt.QCursor(Qt.Qt.OpenHandCursor)) def mouseMoveEvent(self, QMouseEvent): if Qt.Qt.LeftButton and self.flag: self.move(QMouseEvent.globalPos() - self.m_Position) QMouseEvent.accept() def mouseReleaseEvent(self, QMouseEvent): self.flag = False self.setCursor(Qt.QCursor(Qt.Qt.ArrowCursor)) #keyboard answer def keyPressEvent(self, QKeyEvent): if QKeyEvent.key() == 0x60: #0x60 means ` if self.isVisible(): self.hide()
def test_click_to_logo_topmenu_item(web_driver): """Check if the action of the 'Elefant' logo is correct""" homepage = MainPage(web_driver) homepage.click_to_my_choice_topmenu_item(web_driver) homepage.click_to_logo_topmenu_item(web_driver) assert homepage.vote_button_is_enabled(web_driver)
def test_awards_title_two(web_driver): """Check if the title of 'Вхід до голосування' page is correct""" homepage = MainPage(web_driver) homepage.click_to_login_button(web_driver) assert "Голосуйте" in homepage.title_text(web_driver)
def test_click_to_about_button_from_topmenu(web_driver): """Check if the action of 'ПРОЕКТ «СЛОН' on Top-Menu button is correct""" homepage = MainPage(web_driver) about_page = homepage.click_to_about_project_topmenu_item(web_driver) assert 'ЛЕГЕНДА' in about_page.page_content(web_driver)
def Create(self): self.gpInfo = GPInfo() self.wizard = NewWizard(self) self.mainPage = MainPage(self.wizard) # patent rerord self.prGeneralPage = GeneralPage(self.wizard) self.prMedicalPage = MedicalPage(self.wizard) self.prOtherPage = OtherPage(self.wizard) self.prHistoryPage = HistoryPage(self.wizard) self.mainPage.SetPrev(None) self.prGeneralPage.SetPrev(self.mainPage) self.prGeneralPage.SetNext(self.prMedicalPage) self.prMedicalPage.SetPrev(self.prMedicalPage) self.prMedicalPage.SetNext(self.prOtherPage) self.prOtherPage.SetNext(self.prHistoryPage) self.prOtherPage.SetPrev(self.prMedicalPage) self.prHistoryPage.SetNext(None) self.prHistoryPage.SetPrev(self.prOtherPage) # appointment self.apPatentPage = App_PatentPage(self.wizard) self.apTimePage = App_TimePage(self.wizard) self.apPatentPage.SetNext(self.apTimePage) self.apPatentPage.SetPrev(self.mainPage) self.apTimePage.SetNext(None) self.apTimePage.SetPrev(self.apPatentPage) # gps self.gpGeneralPage = GP_GeneralPage(self.wizard, self.gpInfo) self.gpOtherPage = GP_OtherPage(self.wizard, self.gpInfo) self.gpGeneralPage.SetNext(self.gpOtherPage) self.gpGeneralPage.SetPrev(self.mainPage) self.gpOtherPage.SetNext(None) self.gpOtherPage.SetPrev(self.gpGeneralPage) #cpd self.cpdGeneralPage = CPD_GeneralPage(self.wizard, self.gpInfo) self.cpdOtherPage = CPD_OtherPage(self.wizard, self.gpInfo) self.cpdGeneralPage.SetNext(self.cpdOtherPage) self.cpdGeneralPage.SetPrev(self.mainPage) self.cpdOtherPage.SetNext(None) self.cpdOtherPage.SetPrev(self.cpdGeneralPage) #equ self.eqpGeneralPage = Eqp_GeneralPage(self.wizard, self.gpInfo) self.eqpOtherPage = Eqp_OtherPage(self.wizard, self.gpInfo) self.eqpGeneralPage.SetNext(self.eqpOtherPage) self.eqpGeneralPage.SetPrev(self.mainPage) self.eqpOtherPage.SetNext(None) self.eqpOtherPage.SetPrev(self.eqpGeneralPage) self.mainPage.SetOptions([ self.apPatentPage, self.prGeneralPage, self.gpGeneralPage, self.cpdGeneralPage, self.eqpGeneralPage ]) self.wizard.SetPageSize((600, 400))
def test_click_on_my_choise_from_mainpage_unlogined(web_driver): """Check if the action of 'МІЙ ВИБІР' button is correct - unlogined user""" homepage = MainPage(web_driver) my_choise_page = homepage.click_to_my_choice_topmenu_item() assert 'Вхід до голосування' in my_choise_page.content(web_driver)
def test_click_on_login_button_from_mainpage(web_driver): """Check action of the button 'Увійти'""" homepage = MainPage(web_driver) login_page = homepage.click_to_login_button(web_driver) assert "Вхід до голосування" in login_page.page_content(web_driver)
class NewWizard(Wizard): def __init__(self, parent): Wizard.__init__(self, parent, -1, "Mirror Wizard") #self.Bind(Wizard.EVT_WIZARD_FINISHED, self.OnWizardFinished) self.Ok = False def Create(self): self.gpInfo = GPInfo() self.wizard = NewWizard(self) self.mainPage = MainPage(self.wizard) # patent rerord self.prGeneralPage = GeneralPage(self.wizard) self.prMedicalPage = MedicalPage(self.wizard) self.prOtherPage = OtherPage(self.wizard) self.prHistoryPage = HistoryPage(self.wizard) self.mainPage.SetPrev(None) self.prGeneralPage.SetPrev(self.mainPage) self.prGeneralPage.SetNext(self.prMedicalPage) self.prMedicalPage.SetPrev(self.prMedicalPage) self.prMedicalPage.SetNext(self.prOtherPage) self.prOtherPage.SetNext(self.prHistoryPage) self.prOtherPage.SetPrev(self.prMedicalPage) self.prHistoryPage.SetNext(None) self.prHistoryPage.SetPrev(self.prOtherPage) # appointment self.apPatentPage = App_PatentPage(self.wizard) self.apTimePage = App_TimePage(self.wizard) self.apPatentPage.SetNext(self.apTimePage) self.apPatentPage.SetPrev(self.mainPage) self.apTimePage.SetNext(None) self.apTimePage.SetPrev(self.apPatentPage) # gps self.gpGeneralPage = GP_GeneralPage(self.wizard, self.gpInfo) self.gpOtherPage = GP_OtherPage(self.wizard, self.gpInfo) self.gpGeneralPage.SetNext(self.gpOtherPage) self.gpGeneralPage.SetPrev(self.mainPage) self.gpOtherPage.SetNext(None) self.gpOtherPage.SetPrev(self.gpGeneralPage) #cpd self.cpdGeneralPage = CPD_GeneralPage(self.wizard, self.gpInfo) self.cpdOtherPage = CPD_OtherPage(self.wizard, self.gpInfo) self.cpdGeneralPage.SetNext(self.cpdOtherPage) self.cpdGeneralPage.SetPrev(self.mainPage) self.cpdOtherPage.SetNext(None) self.cpdOtherPage.SetPrev(self.cpdGeneralPage) #equ self.eqpGeneralPage = Eqp_GeneralPage(self.wizard, self.gpInfo) self.eqpOtherPage = Eqp_OtherPage(self.wizard, self.gpInfo) self.eqpGeneralPage.SetNext(self.eqpOtherPage) self.eqpGeneralPage.SetPrev(self.mainPage) self.eqpOtherPage.SetNext(None) self.eqpOtherPage.SetPrev(self.eqpGeneralPage) self.mainPage.SetOptions([ self.apPatentPage, self.prGeneralPage, self.gpGeneralPage, self.cpdGeneralPage, self.eqpGeneralPage ]) self.wizard.SetPageSize((600, 400)) #self.Bind(self.EVT_WIZARD_FINISHED, self.OnWizardFinished) def Run(self): if self.wizard.RunWizard(self.mainPage): if self.prHistoryPage.IsDone(): print "New PR" if self.apTimePage.IsDone(): print "New AP" if self.gpOtherPage.IsDone(): self.NewGP() print self.gpInfo print "New GP" if self.cpdOtherPage.IsDone(): self.NewCPD() print "Success" else: print "Canceled" def NewGP(self): gpTable = GPTable() gpTable.add(self.gpGeneralPage.first.GetValue(), self.gpGeneralPage.surname.GetValue(), address=self.gpGeneralPage.address.GetValue(), town=self.gpGeneralPage.town.GetValue(), post_code=self.gpGeneralPage.postcode.GetValue(), home_phone=self.gpGeneralPage.homephone.GetValue(), work_phone=self.gpGeneralPage.workphone.GetValue(), mobile=self.gpGeneralPage.mobile.GetValue(), prefered_phone=self.gpGeneralPage.preferedPhone.GetValue(), email=self.gpGeneralPage.email.GetValue()) #self.gpGeneralPage.title.GetValue() ''' address=None, town=None, post_code=None, home_phone=None, work_phone=None, mobile=None, prefered_phone=None, email=None): self.gpInfo.first = self.gpGeneralPage.first.GetValue() self.gpInfo.surname = self.gpGeneralPage.surname.GetValue() self.gpInfo.address = self.gpGeneralPage.address.GetValue() self.gpInfo.town = self.gpGeneralPage.town.GetValue() self.gpInfo.postcode = self.gpGeneralPage.postcode.GetValue() self.gpInfo.homephone = self.gpGeneralPage.homephone.GetValue() self.gpInfo.workphone = self.gpGeneralPage.workphone.GetValue() self.gpInfo.mobile = self.gpGeneralPage.mobile.GetValue() self.gpInfo.preferedPhone = self.gpGeneralPage.preferedPhone.GetValue() self.gpInfo.email = self.gpGeneralPage.email.GetValue() self.gpInfo.other = self.gpOtherPage.other.GetValue() ''' def NewCPD(self): cpdTable = CPDTable() cpdTable.add( title=self.cpdGeneralPage.title.GetValue(), date_started=self.cpdGeneralPage.date_started.GetValue(), days_taken=self.cpdGeneralPage.days_taken.GetValue(), activity_type=self.cpdGeneralPage.activity_type.GetValue(), category=self.cpdGeneralPage.category.GetValue(), core_cpd_module=self.cpdGeneralPage.core_cpd_module.GetValue(), description=self.cpdGeneralPage.description.GetValue(), learning_objectives=self.cpdGeneralPage.learning_objectives. GetValue(), reflective_comments=self.cpdOtherPage.reflective_comments.GetValue( ), attached_files=None, web_links=None, ) def OnWizardFinished(self, event): #self.cpdGeneralPage.category self.Ok = True print "EVT_WIZARD_FINISHED"
def test_click_to_faq_from_mainpage(web_driver): """Check if the action of 'ПИТАННЯ ТА ВІДПОВІДІ' button on Top-Menu is correct""" homepage = MainPage(web_driver) homepage.click_to_faq_topmenu_item(web_driver) assert 'Питання та відповіді' in homepage.page_content(web_driver)
class Window(QWidget): showMemo = pyqtSignal(bool) def __init__(self, data=None): super(Window, self).__init__() self.initData(data) self.initUi() self.initModule() self.setModule() self.funcLink() #data self.dataLoad() def initData(self, data): self.autohide = False self.data = read(data) self.memoSettings = readMemoSettings(data) self.uiSettings = readMemoUi(data) date = QDate.currentDate() date = date.toString(Qt.ISODate) if self.data['login_date'] != date: self.data['login_date'] = date write(self.data) def funcLink(self): # button self.mainpage.homeBtn.clicked.connect(self.flexSideBar) self.sidebar.newBtn.clicked.connect(self.addMemo) self.sidebar.setBtn.clicked.connect(self.settingMemo) self.sidebar.dataBtn.clicked.connect(self.dataStatistics) self.sidebar.aboutBtn.clicked.connect(self.aboutMemo) def initUi(self): self.setMinimumWidth(600) self.setMaximumWidth(600) self.layout = QHBoxLayout() self.layoutl = QVBoxLayout() self.layoutr = QVBoxLayout() #self.layout.setMargin(0) self.layout.setSpacing(0) # hide menu bar if self.uiSettings['is_up']: self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool | Qt.WindowStaysOnTopHint) else: self.setWindowFlags(Qt.FramelessWindowHint | Qt.Tool) self.setAttribute(Qt.WA_TranslucentBackground) def initModule(self): self.mainpage = MainPage(self) self.sidebar = SideBar(self) self.sidebar.hide() self.tray = TraySet(self) self.tray.show() self.about = AboutMemo() self.about.hide() self.setting = SettingBar(self) self.setting.hide() self.statistics = DataStatistics(self) self.statistics.hide() self.windowIcon = QIcon(css.AppIconPath) self.setWindowIcon(self.windowIcon) self.grabKeyboard() def setModule(self): self.layoutl.addWidget(self.mainpage) self.layoutl.addWidget(self.sidebar) self.layoutl.addStretch(1) #set main layout self.layout.addLayout(self.layoutl) self.layout.addLayout(self.layoutr) self.setLayout(self.layout) def dataLoad(self): content = readMemoContent(self.data) if_done = readMemoPerformance(self.data) if self.data['memo_num'] > 0: for i in range(self.data['memo_num']): info = {} info.update(id=i + 1, content=content[i], if_done=if_done[i]) info.update(self.memoSettings) self.loadMemo(info) def loadMemo(self, data): label = Memo(self, data) allCount = self.layoutr.count() if allCount == 0: self.layoutr.addWidget(label) else: self.layoutr.insertWidget(allCount + 1, label) def addMemo(self): #set dict message about single memo list = self.data['memo_data'] numInfo = len(list) > 0 and list[-1]['id'] or 0 info = {} info.update(id=numInfo + 1) info.update(self.memoSettings) #get the time of creating memo date = QDate.currentDate() date = date.toString(Qt.ISODate) #initialize memo object allCount = self.layoutr.count() label = Memo(self, info) if allCount == 0: self.layoutr.addWidget(label) else: self.layoutr.insertWidget(allCount + 1, label) #save new memo's message memo_data = {} memo_data.update(id=numInfo + 1, content='It is empty!', set_date=date, if_done=[]) self.data['memo_data'].append(memo_data) self.data['memo_num'] = len(list) write(self.data) def aboutMemo(self): self.about.show() def settingMemo(self): self.setting.show() def dataStatistics(self): self.statistics.show() def getTrashPos(self): return self.mainpage.getTrashPos() def flexSideBar(self): if self.sidebar.isHidden(): self.sidebar.show() self.showMemo.emit(True) else: self.sidebar.hide() self.showMemo.emit(False) if self.mainpage.homeLabel.isHidden(): self.mainpage.homeLabel.show() def autoHide(self): x = self.pos().x() y = self.pos().y() desk = QApplication.desktop() if x < -40: self.sidebar.hide() self.showMemo.emit(False) self.move(-65, y) self.autohide = True elif y < -40: self.sidebar.hide() self.showMemo.emit(False) self.move(x, -125) self.autohide = True elif x > desk.width() - 99: self.sidebar.hide() self.showMemo.emit(False) self.move(desk.width() - 65, y) self.autohide = True elif self.autohide: self.sidebar.show() self.showMemo.emit(True) self.autohide = False #move without form def mousePressEvent(self, QMouseEvent): if QMouseEvent.button() == Qt.LeftButton: self.flag = True self.m_Position = QMouseEvent.globalPos() - self.pos() QMouseEvent.accept() self.setCursor(QCursor(Qt.OpenHandCursor)) def mouseMoveEvent(self, QMouseEvent): if Qt.LeftButton and self.flag: self.move(QMouseEvent.globalPos() - self.m_Position) QMouseEvent.accept() def mouseReleaseEvent(self, QMouseEvent): self.flag = False self.setCursor(QCursor(Qt.ArrowCursor)) self.autoHide() #keyboard answer def keyPressEvent(self, QKeyEvent): if QKeyEvent.key() == 0x60: #0x60 means ` if self.isVisible(): self.hide()
def test_click_to_rules_from_mainpage(web_driver): """Check if the action of 'ЯКОГО СЛОНА ОБРАТИ?' on Top-Menu button is correct""" homepage = MainPage(web_driver) homepage.click_to_rules_topmenu_item(web_driver) assert 'ПРАВИЛА ПРОВЕДЕННЯ' in homepage.page_content(web_driver)