def __init__(self, console, parent=None): super(Form, self).__init__(parent) self.console = console self.logger = Logger('Login', Logger.INFO) self.setWindowTitle("PttOTP 登入視窗") self.setMinimumWidth(300) self.setMinimumHeight(150) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowIcon(util.load_icon(config.icon_small)) # Create widgets self.label_id = QLabel('請輸入批踢踢帳號') self.edit_id = QLineEdit() self.edit_id.setAlignment(Qt.AlignHCenter) self.label_pw = QLabel('請輸入批踢踢密碼') self.edit_pw = QLineEdit() self.edit_pw.setAlignment(Qt.AlignHCenter) self.edit_pw.setEchoMode(QLineEdit.Password) self.button = QPushButton("登入") self.button.clicked.connect(self.login) # Create layout and add widgets layout = QVBoxLayout() layout.addWidget(self.label_id) layout.addWidget(self.edit_id) layout.addWidget(self.label_pw) layout.addWidget(self.edit_pw) layout.addWidget(self.button) # Set dialog layout self.setLayout(layout) # Add button signal to greetings slot self.ptt_adapter = None self.next = False
def __init__(self, console): super(type(self), self).__init__() self.bar = QRoundProgressBar(console) self.bar.setFixedSize(300, 300) self.bar.setDataPenWidth(0) self.bar.setOutlinePenWidth(0) self.bar.setDonutThicknessRatio(0.92) self.bar.setDecimals(0) self.bar.setNullPosition(90) self.bar.setBarStyle(QRoundProgressBar.StyleDonut) self.bar.setDataColors([(0., QColor.fromRgb(65, 105, 225))]) self.bar.setRange(0, 29) self.setWindowTitle(f'{console.ptt_id} 驗證碼') lay = QVBoxLayout() lay.addWidget(self.bar) self.setLayout(lay) self.console = console self.timer_thread = None self.call_close = False self.logger = Logger('Progress', Logger.INFO) self.setWindowIcon(util.load_icon(config.icon_small)) self.update_otp()
def __init__(self, console, parent=None): super(Form, self).__init__(parent) flag = self.windowFlags() flag &= ~Qt.WindowCloseButtonHint flag |= Qt.WindowStaysOnTopHint self.setWindowFlags(flag) self.console = console self.logger = Logger('Rule', Logger.INFO) self.setWindowTitle("PttOTP 使用守則") self.setMinimumWidth(250) self.setWindowIcon(util.load_icon(config.icon_small)) rule_text = ''' 以下為 Ptt OTP 使用守則,如不同意或無法遵守 請勿使用本軟體 1. 切勿同一帳號同時執行兩個以上批踢踢動態密碼程式 2. Ptt OTP 會顯示並儲存敏感資訊,請勿在公共電腦上執行 3. 軟體出錯難免,如軟體無法正確還原您的密碼,請使用註冊 信箱取回帳號功能 ''' rule_text = rule_text.strip() layout = QVBoxLayout() for rule_line in rule_text.split('\n'): layout.addWidget(QLabel(rule_line)) # Set dialog layout button_layout = QHBoxLayout() ok_button = QPushButton("我會遵守") ok_button.clicked.connect(self.click_ok) button_layout.addWidget(ok_button) not_ok_button = QPushButton("無法遵守") not_ok_button.clicked.connect(self.click_not_ok) button_layout.addWidget(not_ok_button) layout.addLayout(button_layout) self.setLayout(layout) self.ok = False
def __init__(self, parent, default_path): # Init super().__init__(parent) self.texfiles = () self.geometry("480x320") self.default_path = default_path # Create frames frame_image_select = tk.Frame(self, relief=tk.RAISED) frame_buttons = tk.Frame(self, relief=tk.RAISED) frame_buttons.pack(fill=tk.X, padx=5, pady=5, side=tk.BOTTOM) frame_image_select.pack(fill=tk.BOTH, padx=5, pady=5, expand=tk.TRUE) # Infiles label_infiles = tk.Label(frame_image_select, text="Input images") label_infiles.pack(side=tk.TOP, anchor=tk.E) button_infiles = tk.Button(frame_image_select, image=util.load_icon('icon/open.png'), command=self.select_images) button_infiles.pack(side=tk.RIGHT, anchor=tk.N) text_infiles = tk.Text(frame_image_select, wrap="none", state=tk.DISABLED) text_infiles_scroll = tk.Scrollbar(frame_image_select, orient=tk.VERTICAL, command=text_infiles.yview) text_infiles["yscrollcommand"] = text_infiles_scroll.set text_infiles_scroll.pack(side=tk.RIGHT, anchor=tk.N, fill=tk.Y) text_infiles.pack(side=tk.RIGHT, anchor=tk.N, fill=tk.BOTH, expand=tk.YES) self.text_infiles = text_infiles # Accept buttons button_ok = tk.Button(frame_buttons, text="Done", command=self.accept_ok) button_cancel = tk.Button(frame_buttons, text="Cancel", command=self.accept_cancel) button_ok.pack(side=tk.RIGHT) button_cancel.pack(side=tk.RIGHT) # Make sure parent window is inactive self.transient(parent) self.grab_set() self.wait_window(self)
def __init__(self, console, otp_key, parent=None): super(Form, self).__init__(parent) self.console = console self.otp_key = otp_key self.logger = Logger('Rule', Logger.INFO) self.setWindowTitle("PttOTP 驗證視窗") self.setWindowIcon(util.load_icon(config.icon_small)) self.setWindowFlags(Qt.WindowStaysOnTopHint) rule_text = ''' 1. 請開啟 google authenticator 掃描以下圖片 2. 於下方輸入框輸入 google authenticator 顯示的驗證碼 ''' rule_text = rule_text.strip() layout = QVBoxLayout() for rule_line in rule_text.split('\n'): layout.addWidget(QLabel(rule_line)) label = QLabel() label.setPixmap(QPixmap('./temp.png')) layout.addWidget(label) button_layout = QHBoxLayout() self.otp_edit = QLineEdit() button_layout.addWidget(self.otp_edit) ok_button = QPushButton("驗證") ok_button.clicked.connect(self.click_verify) button_layout.addWidget(ok_button) layout.addLayout(button_layout) self.setLayout(layout) self.ok = False
def __init__(self, console): super(Form, self).__init__(None) self.logger = Logger('OTP', Logger.INFO) self.console = console console.system_alert = self.system_alert self.icon = util.load_icon(config.icon_small) self.setIcon(self.icon) self.set_menu(False) self.setToolTip('Ptt OTP') self.show() self.activated.connect(self.icon_clicked) self.login_success = False self.in_process = False self.about_window_form = None self.show_login_form()
def __init__(self, console, parent=None): super(Form, self).__init__(parent) # self.setWindowFlag(Qt.WindowCloseButtonHint, False) self.console = console self.logger = Logger('About', Logger.INFO) self.setWindowTitle("關於 Ptt OTP") self.setWindowIcon(util.load_icon(config.icon_small)) layout = QVBoxLayout() label = QLabel() pixmap = util.load_icon(config.person_logo) pixmap = pixmap.scaled(300, 300, Qt.KeepAspectRatio) label.setPixmap(pixmap) label.setAlignment(Qt.AlignCenter) layout.addWidget(label) # rule_text = ''' # 開發者: CodingMan # 專案網址: https://github.com/PttCodingMan/PTT-One-Time-Password # ''' # rule_text = rule_text.strip() # for rule_line in rule_text.split('\n'): # label = QLabel(rule_line) # label.setOpenExternalLinks(True) # # label.setText("<a href=\"http://www.qtcentre.org\">QtCentre</a>"); # layout.addWidget(label) MinimumHeight = 20 label = QLabel() layout.addWidget(label) label = QLabel() label.setOpenExternalLinks(True) label.setText(f'Ptt One Time Password v {config.version}') label.setMinimumHeight(MinimumHeight) layout.addWidget(label) label = QLabel() label.setOpenExternalLinks(True) label.setText( '專案網址: <a href=\"https://github.com/PttCodingMan/PTT-One-Time-Password\">https://github.com/PttCodingMan/PTT-One-Time-Password</a>' ) label.setMinimumHeight(MinimumHeight) layout.addWidget(label) label = QLabel() label.setOpenExternalLinks(True) label.setText( '開發者: <a href=\"https://pttcodingman.github.io/\">CodingMan</a>') label.setMinimumHeight(MinimumHeight) layout.addWidget(label) self.setLayout(layout)
def f_init_ui(self): """ Create entire UI """ self.style = ttk.Style() self.style.theme_use("default") self.master.title("Stitch Editor") self.pack(fill=tk.BOTH, expand=True) # Left frame with buttons buttonframe = ttk.Frame(self, relief=tk.RAISED, borderwidth=1) buttonframe.pack(fill=tk.Y, side=tk.LEFT, ipady=2, ipadx=2) # Top frame with options # optionframe = ttk.Frame(self, relief=tk.RAISED, borderwidth=1) # optionframe.pack(fill=tk.X, side=tk.TOP) # Centermost frame mainframe = ttk.Frame(self, relief=tk.RAISED, borderwidth=1) mainframe.pack(side=tk.LEFT, anchor=tk.N + tk.W) self.mainframe = mainframe # Create menu menu_root = tk.Menu(self.master) self.master.config(menu=menu_root) # File menu menu_file = tk.Menu(menu_root, tearoff=0) menu_file.add_command(label="New", command=self.f_stitch_new) menu_file.add_command(label="New Auto", command=self.f_stitch_new_auto) menu_file.add_command(label="Save", command=self.f_stitch_save) menu_file.add_command(label="Save As", command=self.f_stitch_save_as) menu_file.add_command(label="Open", command=self.f_stitch_open) menu_file.add_command(label="Close", command=self.f_stitch_close) menu_file.add_command(label="Exit", command=self.f_quit) menu_root.add_cascade(label="File", menu=menu_file) # Edit menu menu_edit = tk.Menu(menu_root, tearoff=0) menu_edit.add_command(label="Configure Image", command=self.f_config) menu_edit.add_command(label="Move Textures", command=self.f_move_textures) menu_edit.add_command(label="Import Textures", command=self.f_import_textures) menu_root.add_cascade(label="Edit", menu=menu_edit) # Image menu menu_image = tk.Menu(menu_root, tearoff=0) menu_image.add_command(label="Import", command=self.f_import_whole) menu_image.add_command(label="Export", command=self.f_export_whole) menu_root.add_cascade(label="Image", menu=menu_image) # Up/Down buttons button_move_up = ttk.Button(buttonframe, image=util.load_icon('icon/up.png'), command=self.f_move_up) button_move_up.pack(side=tk.TOP, padx=5, pady=5) button_move_down = ttk.Button(buttonframe, image=util.load_icon('icon/down.png'), command=self.f_move_down) button_move_down.pack(side=tk.TOP, padx=5, pady=5) button_move_left = ttk.Button(buttonframe, image=util.load_icon('icon/left.png'), command=self.f_move_left) button_move_left.pack(side=tk.TOP, padx=5, pady=5) button_move_right = ttk.Button(buttonframe, image=util.load_icon('icon/right.png'), command=self.f_move_right) button_move_right.pack(side=tk.TOP, padx=5, pady=5) button_add = ttk.Button(buttonframe, image=util.load_icon('icon/add.png'), command=self.f_add_texture) button_add.pack(side=tk.TOP, padx=5, pady=5) button_remove = ttk.Button(buttonframe, image=util.load_icon('icon/remove.png'), command=self.f_remove_current) button_remove.pack(side=tk.TOP, padx=5, pady=5) button_zoom_in = ttk.Button(buttonframe, image=util.load_icon('icon/zoom_in.png'), command=self.f_zoom_in) button_zoom_in.pack(side=tk.TOP, padx=5, pady=5) button_zoom_out = ttk.Button(buttonframe, image=util.load_icon('icon/zoom_out.png'), command=self.f_zoom_out) button_zoom_out.pack(side=tk.TOP, padx=5, pady=5) # Bind keys self.master.bind("<Left>", self.f_move_left) self.master.bind("<Up>", self.f_move_up) self.master.bind("<Right>", self.f_move_right) self.master.bind("<Down>", self.f_move_down) # Gray out elements self.elements_to_gray.append(button_move_up) self.elements_to_gray.append(button_move_left) self.elements_to_gray.append(button_move_right) self.elements_to_gray.append(button_move_down) self.elements_to_gray.append(button_add) self.elements_to_gray.append(button_remove) self.elements_to_gray.append(button_zoom_in) self.elements_to_gray.append(button_zoom_out) self.elements_to_gray.append((menu_file, "Save")) self.elements_to_gray.append((menu_file, "Save As")) self.elements_to_gray.append((menu_file, "Close")) self.elements_to_gray.append((menu_image, "Export")) self.elements_to_gray.append((menu_image, "Import")) self.elements_to_gray.append((menu_edit, "Configure Image")) self.elements_to_gray.append((menu_edit, "Move Textures")) self.elements_to_gray.append((menu_edit, "Import Textures")) # Set data self.set_data(None) # Override quit button self.master.protocol('WM_DELETE_WINDOW', self.f_quit)