def show_simple_dialog(self): if not self.dialog: self.dialog = MDDialog(title="Set backup account", type="simple", text="hello") self.dialog.open()
def select_path(self, path): '''It will be called when you click on the file name or the catalog selection button. :type path: str; :param path: path to the selected directory or file; ''' self.exit_manager() global finalpath punc = '''/~$%^''' # remove '/' from the path for ele in path: if ele in punc: path1 = path.replace(ele, "") # path1 -> '/' symbol removed filepath /Users\Kripa\Desktop\exconvo.txt to Users\Kripa\Desktop\exconvo.txt tmplist = path1.split(os.sep) # splits the path and is put in the list tmplist # Users\Kripa\Desktop\exconvo.txt to ['Users','Kripa','Desktop','exconvo.txt'] finalpath = "" for wrd in tmplist: finalpath = finalpath + r"\\" + wrd finalpath = "C:" + finalpath # print(finalpath) #C:\\Users\Kripa\Desktop\exconvo.txt with open(finalpath, 'r') as in_file: stripped = (line.strip() for line in in_file) lines = (line.split(",") for line in stripped if line) with open('C:\\Users\\Kripa\\Desktop\\convo.csv', 'w', newline='') as out_file: writer = csv.writer(out_file) writer.writerow(('name', 'msg')) writer.writerows(lines) ct = 0 row_ct1 = 0 row_ct2 = 0 strname = "" # Get no.of messages for both users with open("C:\\Users\\Kripa\Desktop\\convo.csv", 'r') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') for row in csv_reader: # lets tokenise if ct == 0 and row[0] != "name": strname = row[0] ct = ct + 1 if row[0] == strname: row_ct1 = row_ct1 + 1 else: row_ct2 = row_ct2 + 1 screen = Builder.load_string(conv_anal) self.tap_target_view = MDTapTargetView( widget=screen.ids.button, title_text="USER 1 USER 2", description_text=" " + str(row_ct1) + " " + str(row_ct2) + " \nMESSAGES MESSAGES", widget_position="center", title_position="right_top", title_text_size="20sp", outer_radius=250, ) sm.add_widget(screen) # GROOMING if int(self.age.text) < 18: with open("C:\\Users\\Kripa\Desktop\\convo.csv") as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') pred_name = "" p_ct = 0 for row in csv_reader: if p_ct == 0 and row[0] != "name" and row[ 0] != self.username.text: pred_name = row[0] p_ct = p_ct + 1 row[1] = row[1].lower() # convert to lowercase lemr = "" for word in row[1].split(): # Lemmatisation lem = (lemmatizer.lemmatize(word, pos="v")) lem = (lemmatizer.lemmatize(lem)) lemr = lemr + lem + " " no_punct = "" for char in lemr: # Remove punctuation if char not in punctuations: no_punct = no_punct + char data = word_tokenize(no_punct) stopWords = set(stopwords.words('english')) wordsFiltered = [] for w in data: # Remove stopwords if w not in stopWords: wordsFiltered.append(w) fp = "C:\\Users\\Kripa\\Desktop\\exconvo2.csv" with open(fp, 'a+', newline='') as out_file: writer = csv.writer(out_file, delimiter=' ') writer.writerow(wordsFiltered[:20]) # liwc def tokenize(text): for match in re.finditer(r'\w+', text, re.UNICODE): yield match.group(0) parse, category_names = liwc.load_token_parser( "C:\\Users\\Kripa\\Desktop\\bigdic.dic") cntt = array('i', [0, 0, 0, 0, 0, 0]) # Stages predator = "C:\\Users\\Kripa\\Desktop\\exconvo2.csv" with open(predator) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') ct = 0 i = 1 j = 0 for row in csv_reader: p = row.copy() p1 = listtostring(p).lower() p_token = tokenize(p1) from collections import Counter op1 = Counter(category for token in p_token for category in parse(token)) op = dict(op1) l = list(op.keys()) l.sort(reverse=True) if l: j = l[0] if j == "S1": cntt[0] = cntt[0] + 1 if j == "S2": cntt[1] = cntt[1] + 1 if j == "S3": cntt[2] = cntt[2] + 1 if j == "S4": cntt[3] = cntt[3] + 1 if j == "S5": cntt[4] = cntt[4] + 1 if j == "S6": cntt[5] = cntt[5] + 1 ''' cntt[0]=807 cntt[1]=396 cntt[2] =87 cntt[3] =79 cntt[4] =38 cntt[5] =226 ''' clf = joblib.load('svm.pkl') op = clf.predict([cntt]) if op == [1]: mail.main_func(self.username.text, self.mycontact.text, pred_name, "", "", "message1") self.dialog = MDDialog( text= "Grooming characteristics detected. Immediate responders have been informed.", size_hint=(0.8, 1), buttons=[ MDFlatButton(text='Close', on_release=self.close_dialog), ]) self.dialog.open() toast(finalpath) # return sm os.remove("C:\\Users\\Kripa\\Desktop\\exconvo2.csv")
def error_message(self, message): error_popup = MDDialog(title = "Error", text= message, size_hint = [.25, .25]) error_popup.open()
def smart_card_insert(self): Logger.info('SmartCard: Reading data from SmartCard...') Logger.info('SmartCard: Screen - ' + CPECafe.screen_manager.current + ', ' + self.name) if CPECafe.screen_manager.current != self.name: return if self.connect(self.readerIndex) != None: Logger.info('SmartCard: Connected and read data from SmartCard') Logger.info('SmartCard: Last Citizen=%s' % (self.last_citizen)) Logger.info('SmartCard: Citizen=%s' % (self.citizen)) if self.last_citizen != None and self.last_citizen != self.citizen: #Logger.info('SmartCard: R1') if self.smart_card_change == False: if self.smart_card_remove: CPECafe.tsc.smart_card_remove_dialog.dismiss( force=True) CPECafe.tsc.smart_card_remove_dialog = None self.smart_card_remove = False Clock.unschedule(self.check_smart_card_away) self.smart_card_change = True CPECafe.tsc.smart_card_change_dialog = MDDialog( title='แจ้งเตือน...', size=('480dp', '260dp'), size_hint=(None, None), #text="Your Citizen Card was pulled out. Please reinsert your Citizen Card to continue or click 'Cancel' to cancel.", text= "พบว่ามีการเปลี่ยนบัตรประจำตัวประชาชน กรุณาเสียบบัตรประจำตัวประชาชนเดิมเพื่อดำเนินการต่อ หรือเลือก 'Cancel' เพื่อสิ้นสุดการดำเนินการ", text_button_ok='OK', text_button_cancel='Cancel', auto_dismiss=False, events_callback=self.smart_card_remove_dialog_callback) CPECafe.tsc.smart_card_change_dialog.open() else: #Logger.info('SmartCard: R2') if self._card_insert_cb != None: self._card_insert_cb() return if self._wait_for_pull_out: Logger.info('SmartCard: Waiting to pull out the card') if self.smart_card_removable == False: self.smart_card_removable = True CPECafe.tsc.smart_card_removable_dialog = MDDialog( title='แจ้งให้ทราบ...', size=('480dp', '280dp'), size_hint=(None, None), #text="Thank you for using our service. Please pull out your Citizen Card to finish.", text= "ขอบคุณที่ใช้บริการของเรา กรุณาถอดบัตรประจำตัวประชาชนออกจากช่องอ่านบัตรเพื่อสิ้นสุดการดำเนินการ", text_button_ok='Ok', auto_dismiss=False, events_callback=self. wait_for_pull_card_out_dialog_callback) CPECafe.tsc.smart_card_removable_dialog.open() elif self.smart_card_remove: CPECafe.tsc.smart_card_remove_dialog.dismiss(force=True) CPECafe.tsc.smart_card_remove_dialog = None self.smart_card_remove = False Clock.unschedule(self.check_smart_card_away) if self._card_reinsert_cb != None: self._card_reinsert_cb() else: Logger.info('SmartCard: Error reading SmartCard')
def invalidLogin(self): self.pop = MDDialog(text='Invalid username or password.', size_hint=(.5, .3)) self.pop.open()
def show_alert_dialog(app): app.dialog = MDDialog( title='Error!', text='Please select the shape of the waveform!', buttons=[MDFlatButton(text='Dismiss', on_release=close_dialog)]) app.dialog.open()
def check_data_login(self): self.get_permission() toast('Load Module....') try: nama = self.ids.screen1.username.text self.ids.screen1.username.text = '' kelas = self.ids.screen1.kelas.text self.ids.screen1.kelas.text = '' font = self.ids.screen1.spinn.text self.ids.screen1.spinn.text = 'Font' kertas = self.ids.screen1.spinn1.text self.ids.screen1.spinn1.text = 'Paper' isi = self.ids.screen1.isi.text self.ids.screen1.isi.text = '' with open('data/date.json', 'r') as f: self.attempts = json.load(f) try: pass except KeyError: with open('data/date.json', 'w') as fpp: self.attempts[str(date.today())] = 0 json.dump(self.attempts, fpp) with open('data/date.json', 'w') as f: try: self.attempts[str(date.today())] += 1 json.dump(self.attempts, f) except KeyError: with open('data/date.json', 'w') as fpp: self.attempts[str(date.today())] = 0 json.dump(self.attempts, fpp) self.attempts[str(date.today())] += 1 json.dump(self.attempts, f) prs = nulis.Fung(isi, kertas, font, nama, kelas) prs.textNulis() self.ids.screen2.image1.source = prs.return_location() self.change_screen('screen2') print(self.ids.screen_manager.current) except: self.dialog2 = MDDialog( title='No Input ', text='Fill Out The Font and Paper Section', size_hint=(0.5, 1), buttons=[ MDFlatButton(text='Close', on_release=self.close_dialog2), MDRaisedButton(text='Default', on_release=self.default) ]) self.dialog2.open()
def save_dialog(self, obj): username = self.dialog.content_cls.ids.username.text.strip() fullname = self.dialog.content_cls.ids.fullname.text.strip() password = self.dialog.content_cls.ids.password.text.strip() userRole = self.dialog.content_cls.ids.user_role.current_item.strip() self.dialog.content_cls.ids.username.focus = False self.dialog.content_cls.ids.fullname.focus = False self.dialog.content_cls.ids.password.focus = False self.dialog.content_cls.ids.user_role.focus = False if (username == None or len(username) == 0): self.dialog.content_cls.ids.username.error = True return if (fullname == None or len(fullname) == 0): self.dialog.content_cls.ids.fullname.error = True return if ((password == None or len(password) == 0) and self.dialog.content_cls.user.id == None): self.dialog.content_cls.ids.password.error = True self.dialog.content_cls.ids.password.focus = True return if (userRole == None or len(userRole) == 0): self.dialog.content_cls.ids.user_role.error = True return with Database() as db: try: userRepository = UserRepository(db) existedUser = userRepository.find_by_condition( "username='******'".format(username)) if (self.dialog.content_cls.user.id == None): user = User(None, username, fullname, password, userRole) else: user = User(self.dialog.content_cls.user.id, username, fullname, password, userRole) if (user.id == None): if (len(existedUser) == 0): user.password = userRepository.get_hash( None, user.password) userRepository.insert(user) else: self.dialogPopup = MDDialog( title="Warning", text='Username already exist!', size_hint=(.5, 1), buttons=[ MDRaisedButton( text="OK", on_release=self.cancel_dialog_popup) ]) self.dialogPopup.open() return else: if (len(existedUser) == 0 or (len(existedUser) > 0 and existedUser[0]['id'] == user.id)): # If the password not typed than use this method if (user.password == None or len(user.password) == 0): userRepository.updateWithoutPassword(user) else: user.password = userRepository.get_hash( None, user.password) userRepository.update(user) else: self.dialogPopup = MDDialog( title="Warning", text='Username already exist!', size_hint=(.5, 1), buttons=[ MDRaisedButton( text="OK", on_release=self.cancel_dialog_popup) ]) self.dialogPopup.open() return self.dialog.dismiss() self.load_user_list() except DbException as err: self.dialogPopup = MDDialog( title="Error", text="{0}".format(err), size_hint=(.5, 1), buttons=[ MDRaisedButton(text="OK", on_release=self.cancel_dialog_popup) ]) self.dialogPopup.open()
def masters_ok(self): """Checks if master passwords are OK.""" if not check_beta(): alert_dialog = MDDialog( title=self.tr( 'error_missing_master_title', txt_format=self.tr('beta') ), text=self.tr('error_missing_master_text'), auto_dismiss=False, buttons=[ MDFillRoundFlatIconButton( text=self.tr('set_password'), icon='account-key-outline', on_release=lambda x: self.dismiss_and_back( alert_dialog, 'settings' ) ), MDRoundFlatIconButton( text=self.tr('randomize'), icon='dice-multiple-outline', on_release=lambda x: [ self.reset_beta(), alert_dialog.dismiss() ] ) ] ) alert_dialog.open() return False elif not check_alpha(): alert_dialog = MDDialog( title=self.tr( 'error_missing_master_title', txt_format=self.tr('alpha') ), text=self.tr('error_missing_master_text'), auto_dismiss=False, buttons=[ MDFillRoundFlatIconButton( text=self.tr('set_password'), icon='account-key-outline', on_release=lambda x: self.dismiss_and_back( alert_dialog, 'settings' ) ), MDRoundFlatIconButton( text=self.tr('randomize'), icon='dice-multiple-outline', on_release=lambda x: [ self.reset_alpha(), alert_dialog.dismiss() ] ) ] ) alert_dialog.open() return False else: return True
def chess_initt(self): try: results = [] moves = [] dates = [] speed = [] games = [] my_elo = [] my_color = [] opponent_elo = [] opponent_country = [] opponent_name = [] # self.nick = nick # nick = """heru007""" chesscom = """https://www.chess.com/games/archive/""" + self.nick + """? gameOwner=other_game&gameTypes%5B0%5D=chess960 &gameTypes%5B1%5D=daily&gameType=live&page={}""" # print(chesscom) for i in range(1,5): # Get the page text = get(chesscom.format(i)).text # Soupifyd b = BeautifulSoup(text, 'html.parser') # Collect results results += pull_results(b) moves += pull_moves(b) dates += pull_dates(b) speed += pull_speed(b) games += pull_game_links(b) my_elo += pull_player_stats(b)[0] opponent_elo += pull_player_stats(b)[1] opponent_country += pull_player_stats(b)[2] opponent_name += pull_player_stats(b)[3] my_color += pull_player_stats(b)[4] # Check progress # print(i) # Make Df d = {'date': dates, 'result': results, 'moves': moves, 'speed': speed, 'link': games, 'my_elo': my_elo, 'opponent_elo': opponent_elo, 'opponent_country': opponent_country, 'opponent_name': opponent_name, 'color': my_color } games_df = DataFrame(d) # Escreve as partidas em arquivo .csv games_df.to_csv(path_or_buf='chess_games.csv') except Exception: self.dialog = None if not self.dialog: self.dialog = MDDialog( text="Oops! Algo pode ter dado errado", radius=[20, 7, 20, 7], ) self.dialog.open()
def menu_callback(self, instance): print(instance.text) self.menu.dismiss() save_button = MDRaisedButton(text="Save", on_release=self.save_dialog) cancel_button = MDFlatButton(text="Cancel", on_release=self.cancel_dialog) if (instance.text == 'Add New'): user = User(None, '', '', '', UserRole.person.value) self.dialog = MDDialog( type="custom", title="User Information", size_hint=(.5, 1), content_cls=UserInfo({ "user": user, }), buttons=[cancel_button, save_button], ) self.dialog.open() elif (instance.text == 'Edit'): if (len(self.data_tables.get_row_checks()) == 0): self.dialogPopup = MDDialog( title="Warning", text='Select one row!', size_hint=(.5, 1), buttons=[ MDRaisedButton(text="OK", on_release=self.cancel_dialog_popup) ]) self.dialogPopup.open() elif (len(self.data_tables.get_row_checks()) > 1): self.dialogPopup = MDDialog( title="Warning", text='Select only one row!', size_hint=(.5, 1), buttons=[ MDRaisedButton(text="OK", on_release=self.cancel_dialog_popup) ]) self.dialogPopup.open() else: selectedUser = None selected_rows = self.data_tables.get_row_checks() for row in selected_rows: for user in self.userList: if (user['row_no'] == row[0]): selectedUser = user break if (selectedUser != None): break if (selectedUser != None): user = User(selectedUser['id'], selectedUser['username'], selectedUser['fullname'], None, selectedUser['userRole']) self.dialog = MDDialog( type="custom", title="User Information", size_hint=(.5, 1), content_cls=UserInfo({ "user": user, }), buttons=[cancel_button, save_button], ) self.dialog.open() elif (instance.text == 'Delete'): if (len(self.data_tables.get_row_checks()) == 0): pass else: self.selectedUsers = [] for row in self.data_tables.get_row_checks(): selectedUser = None for user in self.userList: if (user['row_no'] == row[0]): selectedUser = user break if (selectedUser != None): self.selectedUsers.append( User(selectedUser['id'], selectedUser['username'], selectedUser['fullname'], selectedUser['password'], selectedUser['userRole'])) if (len(self.selectedUsers) > 0): delete_button = MDRaisedButton(text="Delete", on_release=self.delete_user) cancel_button = MDFlatButton( text="Cancel", on_release=self.cancel_dialog_popup) self.dialogPopup = MDDialog( title="Confirmation", text= 'Are you sure you want to delete the selected rows?', size_hint=(.5, 1), buttons=[cancel_button, delete_button]) self.dialogPopup.open()
def get_registration_values(self): name = self.screen.get_screen('login').ids.user_name_sign.text email = self.screen.get_screen('login').ids.user_email_sign.text img_path = self.screen.get_screen('login').ids.image_path_sign.text password = self.screen.get_screen('login').ids.password_sign.text password2 = self.screen.get_screen('login').ids.password_cnfm_sign.text self.all_value = None flag = 1 erreo_text = '' sql = "SELECT * FROM `user_info` WHERE `Email` = %s" MyCursor.execute(sql, email) data2 = MyCursor.fetchone() if name == '' or email == '' or password == '' or password2 == '': flag = 0 erreo_text = 'Error!!!!!!\nPlease fill up all requirements.' elif password != password2: flag = 0 erreo_text = 'Error!!!!!!\nType same password in both place.' elif len(password) < 6: flag = 0 erreo_text = 'Password is too weak\nMinimum password length 6, containing digits and special character' elif data2: flag = 0 erreo_text = 'Error!!!!!!\nThis email is already registered!!\nTry with other.' if flag == 1: with open(img_path, 'rb') as File_t: binary_img = File_t.read() img_path = binary_img hasher = pyHash() arr = bytes(password, 'utf-8') hasher.update(arr) password = hasher.hexdigest() self.all_value = (name, email, img_path, password) sql = "INSERT INTO `user_info` (`Name`, `Email`, `image`, `Password`) VALUES (%s,%s,%s,%s)" MyCursor.execute(sql, self.all_value) img_name_23 = email.split('@')[0] storeFilePth = f"D:/Working_dir/Programming/Python/MultiScanner/User_images/{img_name_23}.jpg" with open(storeFilePth, 'wb') as img_write: img_write.write(binary_img) img_write.close() conn.commit() o_text = "Congratulation!!\nYour registration is complete\nLogin in your account" closebtn = MDFlatButton(text='OK', on_release=self.close_dialog2) self.dialog2 = MDDialog(title="Congratulation", text=o_text, size_hint=(0.8, 0.5), buttons=[closebtn]) self.dialog2.open() self.screen.get_screen('login').ids.user_name_sign.text = '' self.screen.get_screen('login').ids.user_email_sign.text = '' self.screen.get_screen('login').ids.image_path_sign.text = '' self.screen.get_screen('login').ids.password_sign.text = '' self.screen.get_screen('login').ids.password_cnfm_sign.text = '' else: closebtn = MDFlatButton(text='OK', on_release=self.close_dialog2) self.dialog2 = MDDialog(title="Error", text=erreo_text, size_hint=(0.8, 0.5), buttons=[closebtn]) self.dialog2.open() self.screen.get_screen('login').ids.user_name_sign.text = '' self.screen.get_screen('login').ids.user_email_sign.text = '' self.screen.get_screen('login').ids.image_path_sign.text = '' self.screen.get_screen('login').ids.password_sign.text = '' self.screen.get_screen('login').ids.password_cnfm_sign.text = ''
def syncDatabaseButton(self): if self.manager.pg_con is None: self.cursor.execute( "SELECT remote_database, db_name, db_user, db_pass, db_host, db_port FROM options" ) pg_data = self.cursor.fetchone() self.manager.connectRemoteDatabase(pg_data) pg_con = self.manager.pg_con pg_cursor = self.manager.pg_cursor if pg_con is None: toast("Something went wrong") return pg_cursor.execute("SELECT * FROM accounts") remote_data = pg_cursor.fetchall() self.cursor.execute("SELECT * FROM accounts") local_data = self.cursor.fetchall() pg_cursor.execute("SELECT master_password, salt FROM options") remote_options = pg_cursor.fetchone() self.cursor.execute("SELECT master_password, salt FROM options") local_options = self.cursor.fetchone() if remote_data and local_data: toast("Please, Delete 'accounts' table in the PostgreSQL database") # TODO user can select remote or local database for sync elif local_data: def insert_data_to_remote_database(): pg_cursor.execute("INSERT INTO options VALUES(%s, %s)", local_options) for account in local_data: pg_cursor.execute( "INSERT INTO accounts VALUES(%s, %s, %s, %s, %s)", account) pg_con.commit() toast("Sync Completed") toast("Please wait until Sync is Complete") Thread(target=insert_data_to_remote_database).start() elif remote_data: def syncWithRemoteDatabase(password): encrypted, salt = map(bytes.fromhex, remote_options) cipher = self.manager.createCipher(password, salt) try: result = cipher.decrypt(encrypted[:16], encrypted[16:], None) if result.decode() == password: sync = True except: sync = False if sync: dialog.dismiss() toast("Please wait until Sync is Complete") self.cursor.execute( "UPDATE options SET master_password = ?, salt = ? WHERE master_password = ? AND salt = ?", (*remote_options, *local_options), ) for account in remote_data: self.cursor.execute( "INSERT INTO accounts VALUES(?,?,?,?,?)", account) self.con.commit() self.manager.cipher = cipher toast("Sync Completed") else: toast("Wrong Password") dialog = MDDialog( title="Password of the Remote Backup", type="custom", content_cls=DatabasePasswordDialogContent( hint_text="Password of the Remote Backup"), buttons=[ MDFlatButton(text="Cancel", on_press=lambda x: dialog.dismiss()), MDFlatButton( text="Okay", on_press=lambda x: syncWithRemoteDatabase( dialog.content_cls.ids.password_field.text), ), ], ) dialog.open()
def search(self, input): try: if input != '': input.replace(" ", "") urli = endpoint.request_account_info(input) req = UrlRequest(urli, ca_file=certifi.where(), verify=False) req.wait() #req2=UrlRequest('http://localhost:5000/s/'+input) #req2.wait() #print(req2.result) data = req.result global source global profile global Followers global Followings global Posts global ID global account global real global Post global private global bio global ver account = input profile = input + '.jpg' source = self.profile self.profile = input + '.jpg' source = data['graphql']['user']['profile_pic_url'] Followers = str( data['graphql']['user']['edge_followed_by']['count']) Followings = str( data['graphql']['user']['edge_follow']['count']) Posts = str(data['graphql']['user'] ['edge_owner_to_timeline_media']['count']) bio = data['graphql']['user']['biography'] ID = str(data['graphql']['user']['id']) real = str(data['graphql']['user']['full_name']) ver = data['graphql']['user']['is_verified'] private = data['graphql']['user']['is_private'] p = len(data['graphql']['user']['edge_owner_to_timeline_media'] ['edges']) Post.clear() for i in range(p): url = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'thumbnail_resources'][2]['src'] comments = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'edge_media_to_comment']['count'] likes = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'edge_liked_by']['count'] t = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'is_video'] time = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'taken_at_timestamp'] date = datetime.fromtimestamp(time) shortcode = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'shortcode'] location = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'location'] if (location != None): location = location['name'] h = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i]['node'][ 'edge_media_to_caption']['edges'] hashtags = [] if (len(h) > 0): txt = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i][ 'node']['edge_media_to_caption']['edges'][0][ 'node']['text'] hashtags = txt.split('#') if ((len(txt) > 0 and txt[0] != '#') or txt == ''): hashtags.pop(0) type = 'Photo' count = 0 if (t): type = 'Video' count = data['graphql']['user'][ 'edge_owner_to_timeline_media']['edges'][i][ 'node']['video_view_count'] Post.append({ "url": url, "comments": comments, "likes": likes, "type": type, "date": str(date), "hashtags": hashtags, "shortcode": shortcode, "location": location, "view": count }) self.root.current = 'result' elif (input == ''): dialog = MDDialog(title="Alert", size_hint=(0.8, 0.3), text_button_ok="Ok", text='insert a profile name') dialog.open() except: dialog = MDDialog( title="Error", size_hint=(0.8, 0.3), text_button_ok="Ok", text="There's no profile corresponding to this name ") dialog.open()
def open_gps_access_popup(self): dialog = MDDialog(title="GPS Error", text="You need to enable Gps access for app to work") dialog.size_hint = [.8, .8] dialog.pos_hint = {'center_x': .5, 'center_y': .5} dialog.open()
def errorDialog(self): self.dialog = MDDialog(text="ERROR: Username already registered") self.dialog.open()
def show_stats(self): global StaffID global CLASS global SUBJECT query = "SELECT cs_code FROM staff_class WHERE sid=%s and class=%s and subject=%s" val = ( StaffID, CLASS, SUBJECT, ) tmp_cursor.execute(query, val) result = tmp_cursor.fetchall() if len(result) == 1: cs_code = result[0][0] query = "SELECT count(*) from student_class where cs_code=%s" val = (cs_code, ) tmp_cursor.execute(query, val) result = tmp_cursor.fetchall() strength = result[0][0] months = [ 'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC' ] query = "SELECT MONTH(date),count(distinct DAY(date)) from attendance where cs_code=%s group by MONTH(date)" val = (cs_code, ) tmp_cursor.execute(query, val) result = tmp_cursor.fetchall() table_rows = [] for row in result: q = "select count(*) from attendance where cs_code=%s and MONTH(date)=%s and report='P'" v = ( cs_code, row[0], ) tmp_cursor.execute(q, v) r = tmp_cursor.fetchall() table_rows.append( [months[row[0] - 1], row[1], r[0][0] / row[1]]) class Content(BoxLayout): def __init__(self, *args, **kwargs): super().__init__(**kwargs) self.size_hint_y = None self.height = Window.height * 0.6 self.clear_widgets() if len(table_rows) == 0: lbl = MDLabel(text='No data found', halign='center') self.add_widget(lbl) return data_table = MDDataTable(rows_num=len(table_rows), column_data=[ ("Month", dp(12)), (" Total Classes", dp(13)), (" Average Attendance", dp(18)) ], row_data=table_rows) self.add_widget(data_table) dialog = MDDialog(title="Strength: " + str(strength), size_hint=(0.9, 1), type="custom", content_cls=Content()) dialog.open()
def errorDialog(self): self.dialog = MDDialog(text="ERROR: Invalid login information") self.dialog.open()
def valid_data(self, teacher_diploma, teacher_subject, teacher_classes, dt, pass_date, teacher_mle, teacher_name, teacher_surname): teacher_id = None try: teacher_id = int(teacher_mle) except Exception as e: pass if teacher_diploma == "Diplome": info = "Choisissez le diplome" dialog = MDDialog( title="Renseignements incomplets", auto_dismiss=False, size_hint=(0.5, 0.5), text=info, text_button_ok="Compris", ) dialog.open() return False elif teacher_subject == "Matiere enseignee": info_label = MDLabel() info = "Quelle est la matiere enseignee ?" dialog = MDDialog( title="Renseignements incomplets", auto_dismiss=False, size_hint=(0.5, 0.5), text=info, text_button_ok="Compris", ) dialog.open() return False elif not teacher_classes: info = "Ce professeur n'intervient dans aucune classe ?" dialog = MDDialog( title="Renseignements incomplets", auto_dismiss=False, size_hint=(0.5, 0.5), text=info, text_button_ok="Compris", ) dialog.open() return False elif not dt and not pass_date: info = "La date entrée n'est pas correcte. Elle ne sera donc pas validée si elle était maintenue" dialog = MDDialog( title="Date non correcte", auto_dismiss=False, size_hint=(0.5, 0.5), text=info, text_button_ok="Compris", # on=, ) pass_date = True dialog.open() return False elif not teacher_mle or not teacher_name or not teacher_surname or teacher_id is None: info = "Veuillez vérifier les informations personnelles de ce professeur" dialog = MDDialog( title="Renseignements incomplets", auto_dismiss=False, size_hint=(0.5, 0.5), text=info, text_button_ok="Compris", ) dialog.open() return False else: return True
def error_popup(self, error): """Displays error message (if any)""" self.dialog = MDDialog(text=f"Error: {error}", ) self.dialog.open() self.dialog.open()
def dialog(self, **kwargs): kwargs.update({'events_callback': self.dialog_callback}) self._dialog = MDDialog(**kwargs) self._dialog.open()
def delete_infected(self, ob): dl = MDFlatButton(text="Delete", on_release=self.delete) self.del1_dialog = MDDialog(title="Infected File Name", text=self.f.text, pos_hint={'center_x': 0.5, 'center_y': 0.5}, size_hint=(0.7, 1), buttons=[dl]) self.del1_dialog.open()
def aboutPopUp(self): about_app = MDDialog(title="About Cheers!", text="Created by Orangewood using KivyMD", size_hint=[.5, .5], events_callback=self.close_about_me) about_app.open()
def open_gps_access_popup(self): dialog=MDDialog(title="GPS Error",text="You need to enable to GPS access for the app to function properly") dialog.size_hint=[.8,.8] dialog.pos_hint={'center_x':.5,'center_y':.5} dialog.open()
def invalidForm(self): self.pop = MDDialog(text='Please fill in all inputs', size_hint=(.8, .3)) self.pop.open()
def list_udpate(self): my_dialog_3 = MDDialog(title="List of Updates :", text="no updates now", size_hint=[.8, .2]) my_dialog_3.open()
def open_gps_access_popup(self): dialog = MDDialog(title='GPS Error', text='Enable GPS Access') dialog.size_hint = [.8, .8] dialog.pos_hint = {'center_x': .5, 'center_y': .5} dialog.open()
def on_release(self): dialog = MDDialog(title=self.text, text=str(self.description)) dialog.open()
def on_start(self): c0, c1, c2, c3, c4, c5, c6, c7, c8, c9 = Content0(), Content1( ), Content2(), Content3(), Content4(), Content5(), Content6( ), Content7(), Content8(), Content9() self.contents = [c0, c1, c2, c3, c4, c5, c6, c7, c8, c9] self.tiles = [ 'apple', 'python', 'india', 'android', 'earth', 'space', 'marvel', 'game', 'naming', 'tech' ] self.score_icons = [ 'apple.png', 'python.png', 'india.png', 'android.png', 'earth.png', 'space.png', 'marvel.png', 'game.png', 'naming.png', 'tech.png' ] self.end_load = MDDialog(type='custom', content_cls=QuizLoader()) self.about = MDDialog(type='custom', content_cls=AboutDialog(), buttons=[ MDFlatButton(text='CANCEL', on_release=self.close_dialog, text_color=rgba( 0, 36, 106, 255)) ]) self.dialog = MDDialog(type='custom', content_cls=QuizLoader()) self.confirm_exit_quiz = MDDialog( title='Are you sure to leave ?', text='The current progress will be lost.', type='alert', buttons=[ MDFlatButton(text='CANCEL', text_color=rgba(77, 0, 85, 255), on_release=self.close_dialog), CustButton1() ]) self.confirm_exit_result = MDDialog( title='Are you sure to leave ?', type='confirmation', buttons=[ MDFlatButton(text='CANCEL', text_color=rgba(77, 0, 85, 255), on_release=self.close_dialog), CustButton1() ]) self.confirm_skip = MDDialog(title='Skip Question ?', type='confirmation', buttons=[ MDFlatButton( text='CANCEL', on_release=self.close_dialog, text_color=rgba(0, 36, 106, 255)), CustButton2(text=' SKIP ', on_release=self.switch_qn) ]) self.force_end_dialog = MDDialog( title='Confirm ending the quiz ?', type='confirmation', buttons=[ MDFlatButton(text='CANCEL', on_release=self.close_dialog, text_color=rgba(0, 36, 106, 255)), CustButton2(text=' YES ', on_release=self.force_end_result) ]) self.quit_app_dialog = MDDialog( title='Are you sure to quit the app ?', type='confirmation', buttons=[ MDFlatButton(text='CANCEL', on_release=self.close_dialog, text_color=rgba(0, 36, 106, 255)), CustButton2(text=' QUIT ', on_release=self.stop) ]) self.menu = MDDropdownMenu(items=[{ 'text': 'About', 'height': '30dp', 'bot_pad': '5dp' }], width_mult=2, radius=[dp(4)], selected_color=[150, 150, 150, 150], caller=self.root.ids.tb_dots) self.about.update_height(dp(600)) self.menu.bind(on_release=self.menu_callback) self.set_scoreboard()
def show_dialog(output): dialog = MDDialog(text=output, ) dialog.open()