class UserInterface(QtWidgets.QWidget): def __init__(self, exit_signal): super().__init__() self.user = User() if self.user.user_psw: self.user_dialog = UserDialog(self.user) else: self.user_dialog = UserDialog(self.user, '注册') self.user_dialog.show() self.user_dialog.exec_() if self.user.user_name is None: exit_signal.emit() exit(0) return # 部件 self.user_name_label = QtWidgets.QLabel('用户: ' + self.user.user_name) self.user_level = '普通用户' if self.user.user_name != self.user.admin_name else '超级管理员' self.user_level_label = QtWidgets.QLabel(self.user_level) self.change_psw_button = QtWidgets.QPushButton('修改密码') self.manager_user = QtWidgets.QPushButton('用户管理') self.record_show = QtWidgets.QTextEdit() for i in self.user.get_record(): self.record_show.append(i) self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.user_name_label) self.layout.addWidget(self.user_level_label) self.layout.addWidget(self.change_psw_button) if self.user_level == '超级管理员': self.layout.addWidget(self.manager_user) self.layout.addWidget(self.record_show) self.setLayout(self.layout) self.change_psw_button.clicked.connect(self.change_psw) self.manager_user.clicked.connect(self.user_manager) self.sub_win = None def add_a_new_record(self, text): self.record_show.append(self.user.save_record(text)) @Slot() def change_psw(self): UserDialog(self.user, '修改密码', self.user.user_name).exec_() @Slot() def user_manager(self): model_choose_win = UserManager(self.user, self.add_a_new_record) model_choose_win.show() model_choose_win.activateWindow() self.sub_win = model_choose_win
def ProjectAdd(request): ret = public(request,'app-pro','应用','新增') if request.method == 'POST': form_key = ['name','belongu','devu','examu','remark'] form_value = GetFormPost(request,form_key) app = Application() app.ProjectSave(form_value) return redirect('/application/app/list/') else: users = User() ret['users'] = users.GetUserList() return render_to_response('application/project_add.html',ret)
def getAllUsers(self): rowsCount = XLUtils.getRowCount(Env.dataPath, 'usersData') for r in range(2, rowsCount + 1): currentUser = User() currentUser.name = XLUtils.readData(Env.dataPath, "usersData", r, 1) book = UsersBook() book.ISBNnumber = XLUtils.readData(Env.dataPath, "usersData", r, 2) book.checkoutDate = XLUtils.readData(Env.dataPath, "usersData", r, 3) currentUser.userExistingBooks.append(book) if currentUser.name in self.usersDictionary.keys(): self.usersDictionary[currentUser.name].userExistingBooks.append(book) else: self.usersDictionary[currentUser.name] = currentUser
def ProjectEdit(request,projectid): ret = public(request,'app-pro','应用','编辑') if request.method == 'POST': form_key = ['name','belongu','devu','examu','remark'] form_value = GetFormPost(request,form_key) form_value['id'] = projectid app = Application() app.ProjectUpdate(form_value) return redirect('/application/app/list/') else: users = User() ret['users'] = users.GetUserList() ret['project'] = project.objects.get(id=projectid) return render_to_response('application/project_edit.html',ret)
def User(self): # 构造User界面 if not self.user_page: self.user_page = User() self.user_page.username = config_dict["username"] self.main_page.ids.user.add_widget(self.user_page) print(self.user_page.username)
def addUserInfo(self, name, ISBNnumber, checkoutDate): if name in self.userRepository.usersDictionary.keys(): user = self.userRepository.usersDictionary[name] book = UsersBook() book.ISBNnumber = ISBNnumber book.checkoutDate = checkoutDate user.userExistingBooks.append(book) print("Successfully added User information for user", name, "inside existing user.") return currentUser = User() currentUser.name = name bookData = UsersBook() bookData.ISBNnumber = ISBNnumber bookData.checkoutDate = checkoutDate currentUser.userExistingBooks.append(bookData) self.userRepository.usersDictionary[name] = currentUser print("User", name, " Successfully added.")
def constructUser(arguments): if arguments == None: return None time_arg = "registered_on" arguments[time_arg] = datetime.strptime(arguments[time_arg], rfc_822_format) return User(**arguments)
def add_user(username: str, email: str, country: str, password: str) -> int: if not (country in Countries.get_list()): return 4 for char in ILLEGAL_CHARACTERS: if username.find(char) != -1: return 6 if email.find(char) != -1: return 6 if country.find(char) != -1: return 6 if password.find(char) != -1: return 6 username_regex = "^[0-9a-zA-Z]+$" email_regex = "^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$" if re.search(email_regex, email) == None: return 5 if re.search(username_regex, username) == None: return 6 if len( DatabaseHandler.database.get_table("Users").find_rows( lambda x: x.username == username)) > 0: return 1 elif len( DatabaseHandler.database.get_table("Users").find_rows( lambda x: x.email == email)) > 0: return 2 elif len(password) < 8: return 3 user = User(username, email, country) user.hash_password(password) if DatabaseHandler.database.get_table("Users").add_row(user): return 0 else: return -1
def __init__(self, exit_signal): super().__init__() self.user = User() if self.user.user_psw: self.user_dialog = UserDialog(self.user) else: self.user_dialog = UserDialog(self.user, '注册') self.user_dialog.show() self.user_dialog.exec_() if self.user.user_name is None: exit_signal.emit() exit(0) return # 部件 self.user_name_label = QtWidgets.QLabel('用户: ' + self.user.user_name) self.user_level = '普通用户' if self.user.user_name != self.user.admin_name else '超级管理员' self.user_level_label = QtWidgets.QLabel(self.user_level) self.change_psw_button = QtWidgets.QPushButton('修改密码') self.manager_user = QtWidgets.QPushButton('用户管理') self.record_show = QtWidgets.QTextEdit() for i in self.user.get_record(): self.record_show.append(i) self.layout = QtWidgets.QVBoxLayout() self.layout.addWidget(self.user_name_label) self.layout.addWidget(self.user_level_label) self.layout.addWidget(self.change_psw_button) if self.user_level == '超级管理员': self.layout.addWidget(self.manager_user) self.layout.addWidget(self.record_show) self.setLayout(self.layout) self.change_psw_button.clicked.connect(self.change_psw) self.manager_user.clicked.connect(self.user_manager) self.sub_win = None
elif message_type == MessageType.TRANSACTION: user.transaction_manager.add_transaction(data) elif message_type == MessageType.BLOCK: user.block_manager.add_block(data) elif message_type == MessageType.NEIGHBOR_LIST: user.init_neighbor_list(data) elif message_type == MessageType.LOGOUT: user.remove_neighbor(data) msg = client.receive() if __name__ == '__main__': client = Client() user = User() app = QtWidgets.QApplication(sys.argv) main_form = Form(user.name) main_form.change_status_text("User : %s " % user.name) main_form.register_send_handler(lambda txt: send_transaction(user, client, txt)) logger = logging.getLogger('monitoring') logger.addHandler(MonitoringHandler(main_form)) start(user, client, receive) sys.exit(app.exec())
from Champion.Champ_List import ChampionList from Champion.Score.ScoreCalculator import Scorecalculator from Champion.Score.decisionTree import ScoreAVLTree from Game.CurrentGame import Game from User.User import User CL = ChampionList() CG = Game() name = input("enter your user name below:") perfer = input("enter your champion preference, Example: AD , AP, AR, MR") user = User(name) user.add_prefer(perfer) print( "please enter your champion pool one 1 by one, type end when all champion from your champion pool is enter , " "this tool currently support up to champion with alphabet a-b") champ_input = None while champ_input != "end": champ_input = input("type here") champion = CL.find_champ(champ_input) if champion is None: print( "either champion is not currently supported or name is incorrect") else: user.add_champ_to_pool(champion) print("here is the champion entered so far") print(user.get_pool()) print( "now enter all enemy champion that is selected so far in this game, if all champion are entered, type end" ) champ_input = None
def __init__(self): self.usersDictionary = {} self.user = User()
def __init__(self, parent, controller): """ initialized all the button""" self.champ = None self.CL = ChampionList() self.CG = Game() self.user = User("doesn't matter") self.a = 0 self.a1 = 0 self.a2 = 0 self.a3 = 0 self.a4 = 0 self.e1 = 0 self.e2 = 0 self.e3 = 0 self.e4 = 0 self.e5 = 0 self.controller = controller tk.Frame.__init__(self, parent) background_image = tk.PhotoImage(file="character pic/XDXDXDXD.png") background_label = tk.Label(self, image=background_image) background_label.image = background_image background_label.place(x=0, y=0, relwidth=1, relheight=1) "styling" "SET UP BUTTON FOR CHARACTER SELECTION" x = GUI.Championselectionpage.Championselectionpage achamp_1 = tk.Button( self, text="select Champ1", borderwidth=10, command=lambda: [self.specific_position(1, 'a'), controller.show_frame(x)]) achamp_2 = tk.Button( self, text="select Champ2", command=lambda: [self.specific_position(2, 'a'), controller.show_frame(x)]) achamp_3 = tk.Button( self, text="select Champ3", command=lambda: [self.specific_position(3, 'a'), controller.show_frame(x)]) achamp_4 = tk.Button( self, text="select Champ4", command=lambda: [self.specific_position(4, 'a'), controller.show_frame(x)]) echamp_1 = tk.Button( self, text="select enemy Champ1", borderwidth=10, command=lambda: [self.specific_position(1, 'e'), controller.show_frame(x)]) echamp_2 = tk.Button( self, text="select enemy Champ2", command=lambda: [self.specific_position(2, 'e'), controller.show_frame(x)]) echamp_3 = tk.Button( self, text="select enemy Champ3", command=lambda: [self.specific_position(3, 'e'), controller.show_frame(x)]) echamp_4 = tk.Button( self, text="select enemy Champ4", command=lambda: [self.specific_position(4, 'e'), controller.show_frame(x)]) echamp_5 = tk.Button( self, text="select enemy Champ5", command=lambda: [self.specific_position(5, 'e'), controller.show_frame(x)]) achamp_1.grid(row=0, column=0, padx=50, pady=50, sticky="nsew") achamp_2.grid(row=0, column=1, padx=50, pady=50, sticky="nsew") achamp_3.grid(row=0, column=2, padx=50, pady=50, sticky="nsew") achamp_4.grid(row=0, column=3, padx=50, pady=50, sticky="nsew") echamp_1.grid(row=1, column=0, padx=50, pady=50, sticky="nsew") echamp_2.grid(row=1, column=1, padx=50, pady=50, sticky="nsew") echamp_3.grid(row=1, column=2, padx=50, pady=50, sticky="nsew") echamp_4.grid(row=1, column=3, padx=50, pady=50, sticky="nsew") echamp_5.grid(row=1, column=4, padx=50, pady=50, sticky="nsew") poolbutton = tk.Button( self, text="MainChamp", command=lambda: [self.specific_position(0, 'm'), controller.show_frame(x)]) poolbutton.grid(row=0, column=4, padx=50, pady=50) cpp = self.controller.get_page(recommandationpage) helpbutton = tk.Button( self, text="Press for HELP", command=lambda: controller.show_frame(GUI.helppage.HelpPage)) helpbutton.place(relx=0.8, rely=0.75, anchor="c") resultbutton = tk.Button(self, text="RESULT", command=lambda: [ recommandationpage.outputrecommanded(cpp), controller.show_frame(recommandationpage) ]) resultbutton.place(relx=0.665, rely=0.75, anchor="c")
class ChampionPage(tk.Frame): """the main frame""" def __init__(self, parent, controller): """ initialized all the button""" self.champ = None self.CL = ChampionList() self.CG = Game() self.user = User("doesn't matter") self.a = 0 self.a1 = 0 self.a2 = 0 self.a3 = 0 self.a4 = 0 self.e1 = 0 self.e2 = 0 self.e3 = 0 self.e4 = 0 self.e5 = 0 self.controller = controller tk.Frame.__init__(self, parent) background_image = tk.PhotoImage(file="character pic/XDXDXDXD.png") background_label = tk.Label(self, image=background_image) background_label.image = background_image background_label.place(x=0, y=0, relwidth=1, relheight=1) "styling" "SET UP BUTTON FOR CHARACTER SELECTION" x = GUI.Championselectionpage.Championselectionpage achamp_1 = tk.Button( self, text="select Champ1", borderwidth=10, command=lambda: [self.specific_position(1, 'a'), controller.show_frame(x)]) achamp_2 = tk.Button( self, text="select Champ2", command=lambda: [self.specific_position(2, 'a'), controller.show_frame(x)]) achamp_3 = tk.Button( self, text="select Champ3", command=lambda: [self.specific_position(3, 'a'), controller.show_frame(x)]) achamp_4 = tk.Button( self, text="select Champ4", command=lambda: [self.specific_position(4, 'a'), controller.show_frame(x)]) echamp_1 = tk.Button( self, text="select enemy Champ1", borderwidth=10, command=lambda: [self.specific_position(1, 'e'), controller.show_frame(x)]) echamp_2 = tk.Button( self, text="select enemy Champ2", command=lambda: [self.specific_position(2, 'e'), controller.show_frame(x)]) echamp_3 = tk.Button( self, text="select enemy Champ3", command=lambda: [self.specific_position(3, 'e'), controller.show_frame(x)]) echamp_4 = tk.Button( self, text="select enemy Champ4", command=lambda: [self.specific_position(4, 'e'), controller.show_frame(x)]) echamp_5 = tk.Button( self, text="select enemy Champ5", command=lambda: [self.specific_position(5, 'e'), controller.show_frame(x)]) achamp_1.grid(row=0, column=0, padx=50, pady=50, sticky="nsew") achamp_2.grid(row=0, column=1, padx=50, pady=50, sticky="nsew") achamp_3.grid(row=0, column=2, padx=50, pady=50, sticky="nsew") achamp_4.grid(row=0, column=3, padx=50, pady=50, sticky="nsew") echamp_1.grid(row=1, column=0, padx=50, pady=50, sticky="nsew") echamp_2.grid(row=1, column=1, padx=50, pady=50, sticky="nsew") echamp_3.grid(row=1, column=2, padx=50, pady=50, sticky="nsew") echamp_4.grid(row=1, column=3, padx=50, pady=50, sticky="nsew") echamp_5.grid(row=1, column=4, padx=50, pady=50, sticky="nsew") poolbutton = tk.Button( self, text="MainChamp", command=lambda: [self.specific_position(0, 'm'), controller.show_frame(x)]) poolbutton.grid(row=0, column=4, padx=50, pady=50) cpp = self.controller.get_page(recommandationpage) helpbutton = tk.Button( self, text="Press for HELP", command=lambda: controller.show_frame(GUI.helppage.HelpPage)) helpbutton.place(relx=0.8, rely=0.75, anchor="c") resultbutton = tk.Button(self, text="RESULT", command=lambda: [ recommandationpage.outputrecommanded(cpp), controller.show_frame(recommandationpage) ]) resultbutton.place(relx=0.665, rely=0.75, anchor="c") """ set the current champion inorder for button to output the correct image""" def get_champ(self): """get back the result from championselection frame for the purpose of outputting correct champion icon""" y = GUI.Championselectionpage.Championselectionpage cp = self.controller.get_page(y) self.champ = cp.champ champ = self.CL.find_champ(self.champ) x = "character pic/{}Square.png".format(self.champ) photo = tk.PhotoImage(file=x) if self.a1 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(1, 'a'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=0, column=0, padx=50, pady=50) self.CG.add_champ(champ, 1, 'a') if self.a2 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(2, 'a'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=0, column=1, padx=50, pady=50) self.CG.add_champ(champ, 2, 'a') if self.a3 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(3, 'a'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=0, column=2, padx=50, pady=50) self.CG.add_champ(champ, 3, 'a') if self.a4 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(4, 'a'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=0, column=3, padx=50, pady=50) self.CG.add_champ(champ, 4, 'a') if self.e1 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(1, 'e'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=1, column=0, padx=50, pady=50) self.CG.add_champ(champ, 1, 'e') if self.e2 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(2, 'e'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=1, column=1, padx=50, pady=50) self.CG.add_champ(champ, 2, 'e') if self.e3 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(3, 'e'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=1, column=2, padx=50, pady=50) self.CG.add_champ(champ, 3, 'e') if self.e4 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(4, 'e'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=1, column=3, padx=50, pady=50) self.CG.add_champ(champ, 4, 'e') if self.e5 == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(5, 'e'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=1, column=4, padx=50, pady=50) self.CG.add_champ(champ, 5, 'e') if self.a == 1: cb = tk.Button(self, image=photo, command=lambda: [ self.specific_position(0, 'm'), self.controller.show_frame(y) ]) cb.image = photo cb.grid(row=0, column=4, padx=50, pady=50) self.user.add_prefer(champ) def reset_pos(self): """ reset the value correspond to which champion slot should be output""" self.a = 0 self.a1 = 0 self.a2 = 0 self.a3 = 0 self.a4 = 0 self.e1 = 0 self.e2 = 0 self.e3 = 0 self.e4 = 0 self.e5 = 0 def specific_position(self, position, team): """ specific the current champion slot by setting the attribute of the current focused champion slot""" if position == 0: self.reset_pos() self.a = 1 if team == 'a': if position == 1: self.reset_pos() self.a1 = 1 if position == 2: self.reset_pos() self.a2 = 1 if position == 3: self.reset_pos() self.a3 = 1 if position == 4: self.reset_pos() self.a4 = 1 if team == 'e': if position == 1: self.reset_pos() self.e1 = 1 if position == 2: self.reset_pos() self.e2 = 1 if position == 3: self.reset_pos() self.e3 = 1 if position == 4: self.reset_pos() self.e4 = 1 if position == 5: self.reset_pos() self.e5 = 1
"""Contacts. Séparez le programme en plusieurs modules et packages, en ajoutant les fichiers __init__.py et les imports si necessaire. Vérifiez que le programme s'éxecute correctement en lancant main.py depuis la racine du projet. """ from User.User import User from Contact.Abstract import send_mass_messages from Contact.Text import TextContactSystem from Contact.Owl import OwlContactSystem # Our main program. alice = User("Alice", TextContactSystem("0102030405")) bob = User("Bob", OwlContactSystem("4 Privet Drive")) user_list = [alice, bob] send_mass_messages("Hello {name}, Comment vas-tu?", user_list) send_mass_messages( "Salut {name}. Tes informations de contact sont-elles corrects?" " Nous avons celles-ci: {contact_info}.", user_list, )