def __init__(self, master, singles): """ Second setup dialog. Gets further setup information for match. @type master: Toplevel widget @param master: Main application window. @type singles: boolean @param singles: Flag, True if this is a singles match. """ tk.Toplevel.__init__(self, master) self.overrideredirect(1) # No window decorations, no way to close window self.geometry('+100+100') self.noEndingTiebreak = tk.BooleanVar() self.noEndingTiebreak.set(False) self.mensMatch = tk.IntVar() self.mensMatch.set(0) self.matchType = tk.StringVar(self) self.matchType.set(mtypeList[4]) # default value tk.Radiobutton(self, indicatoron = 0, text="Women's match", padx = 20, width=width1 , variable = self.mensMatch, value = 0, anchor='center').pack() tk.Radiobutton(self, indicatoron = 0, text="Men's match", padx = 20, width=width1, variable = self.mensMatch, value = 1, anchor='center').pack() if not singles: # Doubles match tk.Radiobutton(self, indicatoron = 0, text="Mixed doubles", padx = 20, width=width1, variable = self.mensMatch, value = 2, anchor='center').pack() self.noEndingTiebreakBox = tk.Checkbutton(self, variable=self.noEndingTiebreak, onvalue=True, offvalue=False, text="No ending tiebreaker").pack() tk.Label(self, text='Match Type:').pack(side='left') w = tk.OptionMenu(self, self.matchType, *mtypeList) w.config(bg='black',fg='white') w["menu"].config(bg='black',fg='white') w.pack() self.nextButton = tk.Button(self, text='Next', width=8) self.nextButton.pack(side='left') self.title("Match Info #2") # Won't have any effect, given no decorations util.center(self)
def _align_ends(self, m): c2 = util.center(self.ref_motif.ends[0].atoms) closest = None best = 10000 for i, end in enumerate(m.ends): c1 = util.center(end.atoms) dist = util.distance(c1, c2) if dist < best: best = dist closest = end updated_ends = [ closest ] for i, end in enumerate(m.ends): if end != closest: updated_ends.append(end) for i, end in enumerate(updated_ends): flip_res = 0 for c in m.chains(): if c.first().uuid == end.res2.uuid: flip_res = 1 break if c.last().uuid == end.res1.uuid: flip_res = 1 break #print end.name(), flip_res if flip_res: updated_ends[i].res1, updated_ends[i].res2 = \ updated_ends[i].res2, updated_ends[i].res1 m.ends = updated_ends
def initUI(self): #中心布局 self.setCentralWidget(CenterWidget(self)) #菜单栏设置 menu = self.menuBar().addMenu('账号中心') signoutAct = QAction('注销', self) signoutAct.triggered.connect(self.onSignout) menu.addAction(signoutAct) exitAct = QAction('退出', self) exitAct.triggered.connect(self.onExit) menu.addAction(exitAct) #整体布局 self.resize(450, 300) util.center(self) self.setFont(QFont("Microsoft YaHei", 11)) self.setWindowTitle('电子投票系统') self.setWindowIcon(QIcon('./image/user.png')) self.bottomlbl = QLabel() self.bottomlbl.setFont(QFont("宋体")) self.statusBar().addPermanentWidget(self.bottomlbl) self.showbottom()
def initUI(self): user = QLabel('账号: ') pwd = QLabel('密码: ') cpwd = QLabel('确认:') self.userInput = QLineEdit() self.userInput.setPlaceholderText('自定义您的用户名') self.pwdInput = QLineEdit() self.pwdInput.setPlaceholderText('请输入您的密码') self.pwdInput.setEchoMode(QLineEdit.Password) #密码不以明文显示 self.cpwdInput = QLineEdit() self.cpwdInput.setPlaceholderText('请再次输入密码') self.cpwdInput.setEchoMode(QLineEdit.Password) self.registerButton = QPushButton('注册', self) self.registerButton.setIcon(QIcon('./image/register.png')) self.registerButton.clicked.connect(self.onRegister) self.loginButton = QPushButton('登录', self) self.loginButton.setFont(QFont('黑体')) self.loginButton.setIcon(QIcon('./image/start.png')) self.loginButton.clicked.connect(self.onLogin) formlayout = QFormLayout() formlayout.addRow(user, self.userInput) formlayout.addRow(pwd, self.pwdInput) formlayout.addRow(cpwd, self.cpwdInput) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(self.registerButton) hbox.addStretch(1) vbox = QVBoxLayout() vbox.addLayout(formlayout) vbox.addLayout(hbox) centerFrame = QFrame(self) centerFrame.setFrameShape(QFrame.WinPanel) centerFrame.setLayout(vbox) downhbox = QHBoxLayout() downhbox.addStretch(1) downhbox.addStretch(1) downhbox.addWidget(self.loginButton) totalLayout = QVBoxLayout() totalLayout.addWidget(centerFrame) totalLayout.addLayout(downhbox) self.setLayout(totalLayout) self.resize(350, 250) util.center(self) self.setFont(QFont('宋体', 10)) self.setWindowTitle('注册') self.setWindowIcon(QIcon('./image/record.png'))
def window_resize(self, width: int, height: int): center_x = center(display.size[0], ColorSample.get_width_by_radius(self.radius)) y_offset = center(display.size[1], self.radius * 9.6) self.objects = [] for i in range(len(Color.SAMPLE_PALETTES)): x, y = center_x, i * self.radius * 4 + y_offset self.objects.append(ColorSample(x, y, self.radius, *Color.SAMPLE_PALETTES[i])) self.objects.append(Text(x + self.font.size // 3, y - self.font.size * 1.5, chr(i + ord('G')), self.font))
def window_resize(self, width: int, height: int): self.circle.window_resize(width, height) self.elapsed_time.y = self.circle.center_y - self.elapsed_time.font.size / 2 self.elapsed_microsecond.y = self.elapsed_time.y + self.elapsed_time.font.size self.time.window_resize(width, height) self.start_text.x = center(width, self.start_text.width) self.start_text.y = self.time.y - self.start_text.font.size self.elapsed_days.x = center(width, self.elapsed_days.width) self.elapsed_days.y = self.elapsed_time.y - self.elapsed_days.font.size
def createDialog(parent, title, labelText): top = Toplevel(parent) top.transient(parent) top.grab_set() if len(title) > 0: top.title(title) Label(top, text=labelText, font=("", 15)).pack() top.bind("<Return>", ok) b = Button(top, text="OK", command=lambda: ok(top)) b.pack(pady=5) Util.center(top)
def generate(image, width=4096, height=4096): image_width, image_height, image_bands = image.shape left = center(image_width, width) top = center(image_height, height) result = np.zeros((width, height, image_bands), dtype=image.dtype) result[left:left+image_width, top:top+image_height] = image result = rgb2hsv(result) flattened = result.view(hsv_dtype) flattened.shape = -1 # Throws an exception if a copy must be made flattened[np.argsort(flattened, order=['H', 'S', 'V'])] = get_hsv_spectrum() return hsv2rgb(result).view(image.dtype)
def __init__(self): super().__init__() self.radius = 50 center_x = center(display.size[0], ColorSample.get_width_by_radius(self.radius)) y_offset = center(display.size[1], self.radius * 9.6) self.font = Font(constants.NANUMSQUARE_BOLD_FONT, self.radius // 3 * 2, constants.TEXT_COLOR) for i in range(len(Color.SAMPLE_PALETTES)): x, y = center_x, i * self.radius * 4 + y_offset self.objects.append(ColorSample(x, y, self.radius, *Color.SAMPLE_PALETTES[i])) self.objects.append(Text(x + self.font.size // 3, y - self.font.size * 1.5, chr(i + ord('G')), self.font))
def generate(image, width=4096, height=4096): image_width, image_height, image_bands = image.shape left = center(image_width, width) top = center(image_height, height) result = np.zeros((width, height, image_bands), dtype=image.dtype) result[left:left + image_width, top:top + image_height] = image result = rgb2hsv(result) flattened = result.view(hsv_dtype) flattened.shape = -1 # Throws an exception if a copy must be made flattened[np.argsort(flattened, order=['H', 'S', 'V'])] = get_hsv_spectrum() return hsv2rgb(result).view(image.dtype)
def get_residue_state(r, type=ResidueStateType.NORM): phos_atoms, sugar_atoms, base_atoms = [], [], [] for i, a in enumerate(r.atoms): if a is None: continue if i < 3: phos_atoms.append(a) elif i < 12: sugar_atoms.append(a) else: base_atoms.append(a) return ResidueState3Bead(r.uuid, util.center(sugar_atoms), util.center(base_atoms), util.center(phos_atoms), type)
def d(self): """ gets the center of the atoms in this basepair. :return: center of mass of basepair :rtype: np.array """ return util.center(self.atoms)
def tick(self): now = datetime.now() constants.progress = (now.second + now.microsecond / 1000000) / 60 self.circle.tick() delta = now - self.start_time self.elapsed_time.set_text(str(delta % timedelta(days=1)).split('.')[0]) self.elapsed_time.x = center(display.size[0], self.elapsed_time.width) self.elapsed_microsecond.set_text(f'.{delta.microseconds:06d}') self.elapsed_microsecond.x = center(display.size[0], self.elapsed_microsecond.width) self.days = delta // timedelta(days=1) if self.days: self.elapsed_days.set_text(f'{self.days} day' + ('' if self.days == 1 else 's')) self.elapsed_days.x = center(display.size[0], self.elapsed_days.width) self.time.tick()
def state(self): """ gets the state of this basepair and makes sure that the center and sugar positions are updated """ d = util.center(self.atoms) self.bp_state.d = d self.bp_state.sugars = self.c1_prime_coords() return self.bp_state
def __init__(self, master): """ @type master: Toplevel widget @param master: Main application window. """ tk.Toplevel.__init__(self, master) self.overrideredirect(1) # No window decorations, no way to close window self.geometry('+100+100') self.doublesMatch = tk.BooleanVar() self.doublesMatch.set(0) tk.Radiobutton(self, indicatoron = 0, text="Singles", padx = 20, variable = self.doublesMatch, value = False, width = width1, anchor='center').pack() tk.Radiobutton(self, indicatoron = 0, text="Doubles", padx = 20, variable = self.doublesMatch, value = True, width = width1, anchor='center').pack() self.nextButton = tk.Button(self, text='Next', width=8) self.nextButton.pack(side='left') self.title("Match Info #1") # Won't have any effect, given no decorations util.center(self)
def render(self, surface: Surface): if self.line or self.surface_background_width > 3: margin = 5 pygame.draw.rect( surface, self.background_color, ((center(surface.get_width(), self.surface_background_width + margin * 4), self.y - margin), (self.surface_background_width + margin * 4, self.surface.get_height() + margin * 2))) surface.blit(self.surface, (self.x, self.y))
def _align_chains(self, m): chains = m.chains() closest = None best = 1000 best_i = -1 c2 = util.center(self.ref_motif.ends[0].atoms) for i, c in enumerate(chains): c1 = util.center(c.first().atoms) dist = util.distance(c1, c2) if dist < best: best = dist closest = c best_i = i updated_chains = [closest] for i, c in enumerate(chains): if c != closest: updated_chains.append(c) m.structure.chains = updated_chains
def main(): global root, canvas, nextButton, labelMolecule, labelNameMolecule root.title("Estructura de Lewis") root.geometry("1024x720") root.resizable(width=False, height=False) Util.center(root) mainFrame = ttk.Frame(root, padding="20") fileButton = ttk.Button(mainFrame, text="Abrir archivo", command=openFile) nextButton = ttk.Button(mainFrame, text="Siguiente estructura", command=readMolecule) canvas = Canvas(mainFrame, width=790, height=500, bg="grey") labelMolecule = ttk.Label(mainFrame, font=("", 20)) labelNameMolecule = ttk.Label(mainFrame, font=("", 20)) fileButton.pack() labelMolecule.pack() canvas.pack() labelNameMolecule.pack() nextButton.pack() mainFrame.pack() root.mainloop()
def __init__(self, width, height, root_object_manager: RootObjectManager, timeout=1): self.width = width self.height = height self.root_object_manager = root_object_manager self.timeout = timeout self.start_time = time() self.background = Surface((300, 200)) self.background.fill(BACKGROUND_COLOR) self.background.set_alpha(127) self.background_x = center(self.width, self.background.get_width()) self.background_y = center(self.height, self.background.get_height()) self.surface = Font(NANUMSQUARE_BOLD_FONT, 36, TEXT_COLOR).render(f'{width}x{height}') self.x = center(self.width, self.surface.get_width()) self.y = center(self.height, self.surface.get_height()) self.root_object_manager.remove_by_class(ResizeAlert)
def tick(self): now = datetime.now() constants.progress = (now - self.start_time) / (self.target - self.start_time) self.circle.tick() self.last_time.set_text(str(self.target - now)) self.last_time.x = center(display.size[0], self.last_time.width) self.time.tick() if constants.progress >= 1: self.state_manager.state = Clock() if Timer.PLAY_SOUND: play_wav(Timer.END_SOUND)
def _get_state(self, r): """ helper function to setup basepair state object that keeps track of the rotation, center and c1' sugar atoms used to align to this basepair :param r: orientation matrix defining principle axes of coordinate system :type r: np.array :return: basepair state object for this basepair :rtype: BasepairState """ d = util.center(self.atoms) sugars = [ self.res1.get_atom("C1'").coords, self.res2.get_atom("C1'").coords ] return BasepairState(r, d, sugars)
def center(array): """ Shifts the array such that it is centered at the mean. This also changes this mean, because part of the part of the array shifted outside the shape is deleted. """ # weighted mean of image, weighted by pixel value c_x, c_y = util.center(array) # grab height and width from the shape h, w = array.shape # calculate offset shift_x = w // 2 - c_x shift_y = h // 2 - c_y # return center-shifted image return ndimage.shift(array, (shift_x, shift_y))
def get_beads(self): """ Generates steric beads required for checking for steric clashes between motifs. Each residues has three beads modeled after the typical three bead models used in coarse grain modeling. The three beads are: Phosphate: P, OP1, OP2\n Sugar : O5',C5',C4',O4',C3',O3',C1',C2',O2'\n Base : All remaining atoms if there are for example no phosphate atoms only 2 beads will be returned. .. code-block:: python >>> import rnamake.unittests.instances >>> r = rnamake.unittests.instances.residue() >>> r.get_beads() [<Bead(btype='SUGAR', center='-24.027 -48.5001111111 86.368')>, <Bead(btype='BASE', center='-21.2186363636 -52.048 85.1157272727')>] """ phos_atoms, sugar_atoms, base_atoms = [], [], [] for i, a in enumerate(self.atoms): if a is None: continue if i < 3: phos_atoms.append(a) elif i < 12: sugar_atoms.append(a) else: base_atoms.append(a) beads = [] types = [BeadType.PHOS, BeadType.SUGAR, BeadType.BASE] for i, alist in enumerate([phos_atoms, sugar_atoms, base_atoms]): if len(alist) > 0: beads.append(Bead(util.center(alist), types[i])) return beads
def PCA_angle(array): """ Computes the angle of the principal component of the array """ # https://stats.stackexchange.com/questions/113485/weighted-principal-components-analysis from itertools import product from scipy import sparse as sp # Mass center of image (white pixels are heavier) c = util.center(array) h, w = array.shape # Get an array of the coordinates of the image X = np.array(list(product(range(h), range(w)))) # zero-shift mass center X -= c # Use pixel values as weights W = sp.spdiags(array.reshape(h * w), 0, h * w, h * w) W_sum = np.sum(array) # Compute the covariance matrix cov = X.T @ W @ X / W_sum # Find the eigenvectors of the svd u, _s, _v = np.linalg.svd(cov) # print(u, _s, _v) # Get the angle of the principal component # Not sure why these components work, possible source of future bug angle = np.arctan2(u[1, 1], u[0, 1]) return angle
def center_x(self): self.x = center(display.size[0], self.width)
def __init__(self, master): """ @type master: Toplevel widget @param master: Main application window. """ tk.Toplevel.__init__(self, master, bg=mainBackground) self.protocol('WM_DELETE_WINDOW', self.master.destroy) # should probably be self.exit self.overrideredirect(1) # No window decorations, no normal way to close window (added below) self.geometry('+'+xLoc+'+'+yLoc) # Messages self.messageCtrl = tk.Label(self, width = messageWidth, bg=normalMsgBackground, fg=normalMsgForeground, justify='center') self.messageCtrl.config(font=(fontFace, msgFontSize, fontMod)) self.messageCtrl.grid(row=0,column=messageCol,columnspan=messageSpan) # Player / Team names # First team / player self.team1Ctrl = tk.Label(self, width = nameWidth, bg=mainBackground, fg=mainForeground, anchor='w') self.team1Ctrl.config(font=myFont) self.team1Ctrl.grid(row=1, column=nameCol, sticky='W') # Second team / player self.team2Ctrl = tk.Label(self, width = nameWidth, bg=mainBackground, fg=mainForeground, anchor='w') self.team2Ctrl.config(font=myFont) self.team2Ctrl.grid(row=2, column=nameCol, sticky='W') # Who is serving self.team1Serve = tk.Label(self, width = serverWidth, bg=mainBackground, fg=mainForeground, justify='center') self.team1Serve.config(font=myFont) self.team1Serve.grid(row=1, column=serverCol) self.team2Serve = tk.Label(self, width = serverWidth, bg=mainBackground, fg=mainForeground, justify='center') self.team2Serve.config(font=myFont) self.team2Serve.grid(row=2, column=serverCol) # Game score self.gameScoreTeam1 = tk.Label(self, width=gameWidth, bg=normalGameScoreBackground, fg=normalGameScoreForeground, justify='center') self.gameScoreTeam1.config(font=myFont) self.gameScoreTeam1.grid(row=1, column=firstSetCol+1) self.gameScoreTeam2 = tk.Label(self, width=gameWidth, bg=normalGameScoreBackground, fg=normalGameScoreForeground, justify='center') self.gameScoreTeam2.config(font=myFont) self.gameScoreTeam2.grid(row=2, column=firstSetCol+1) # Are we currently in a tiebreak? self.tiebreak = False self.currentSet = 0 # Set scores self.team1SetCtrl = [] self.team2SetCtrl = [] # Flag labels for flags based on player countries: self.flag1 = tk.Label(self) # First team, player 1 self.flag1a = tk.Label(self) # First team, player 2 self.flag2 = tk.Label(self) # Second team, player 1 self.flag2a = tk.Label(self) # Second team, player 2 self.flagImages = [] # Will just be used to keep a reference to flag images (so not garbage collected) self.playerImages = [] # Will just be used to keep a reference to player images (so not garbage collected) # Team ranking labels self.rank1 = tk.Label(self, width=rankWidth, bg=mainBackground, fg=mainForeground, justify='center', font=myFont) self.rank2 = tk.Label(self, width=rankWidth, bg=mainBackground, fg=mainForeground, justify='center', font=myFont) self.rank1.grid(row=1, column=rankCol) self.rank2.grid(row=2, column=rankCol) # Button for exiting the program btnGroup = tk.LabelFrame(self, bg=mainBackground, fg=mainForeground) # may want to move this around for different sets. Or, put it before message control # As of right now, I like it showing above first set score, and staying there. btnGroup.grid(row=0, column=buttonCol, padx=10, pady=10) self.exitButton = tk.Button(btnGroup, text=u'\u2716', bg=mainBackground, fg=mainForeground) # Not 100% happy with this symbol. Seems it should be wider. # For now, removing minimize button. It doesn't work in combination with overrideredirect #self.minimizeButton = tk.Button(btnGroup, text=u'\u02cd', bg=mainBackground, fg=mainForeground) self.exitButton.config(command=lambda: self.exit()) # quit application #self.minimizeButton.config(command=lambda: self.wm_state('iconic')) # minimize scoreboard #self.minimizeButton.grid(row=0, column=0, sticky='E') self.exitButton.grid(row=0, column=1, sticky='E') self.title("Scoreboard") #no effect with overrideredirect util.center(self) self.readCountries()
def window_resize(self, width: int, height: int): self.circle.window_resize(width, height) self.last_time.y = self.circle.center_y + self.circle.circle_progress.font.size / 2 self.time.window_resize(width, height) self.target_time.x = center(width, self.target_time.width) self.target_time.y = self.time.y - self.target_time.font.size
def tick(self): loop_time = time() if self.keyboard_manager.is_start(pygame.K_BACKSPACE): self.backspace_pressed_time = time() if self.keyboard_manager.is_pressed(pygame.K_BACKSPACE) and \ self.backspace_sleep_duration + self.backspace_pressed_time <= time(): self.backspace_cycle_elapsed += loop_time - self.last_loop_time if self.backspace_cycle_elapsed >= self.backspace_repress_cycle: self.line += '\b' self.backspace_cycle_elapsed -= self.backspace_repress_cycle self.line += self.keyboard_manager.pop_buffer() while '\x7f' in self.line: i = self.line.index('\x7f') self.line = self.line[:i - 1] + self.line[i + 1:] while '\b' in self.line: i = self.line.index('\b') self.line = self.line[:i - 1] + self.line[i + 1:] self.surface = self.font.render(self.line) self.surface_background_width += \ (self.surface.get_width() - self.surface_background_width) / constants.FRICTION start_time = center(display.size[0], self.surface.get_width()) self.x += (start_time - self.x) / (constants.FRICTION / 3) if self.keyboard_manager.is_start(pygame.K_ESCAPE): self.line = '' elif self.line == 'c\n': self.state_manager.state = Clock() elif len(self.line) > 1 and ( self.keyboard_manager.is_start(pygame.K_RETURN) or self.keyboard_manager.is_start(pygame.K_KP_ENTER)): self.line = self.line.lower() # noinspection SpellCheckingInspection if self.line[-2] == '.': self.alarm(self.line) elif self.line[-2] == '`': self.timer(self.line) elif self.line[-2] == '/': now = datetime.now() year, day = 0, 0 hour, minute, second = 0, 0, 0 change = True try: minute += float(self.line[:-2]) except ValueError: try: tmp = float(self.line[:-3]) except ValueError: change = False else: if self.line[-3].lower() == 's': second += tmp elif self.line[-3].lower() == 'h': hour += tmp elif self.line[-3].lower() == 'd': day += tmp elif self.line[-3].lower() == 'y': year += tmp while second > 60: second -= 60 minute += 1 while minute > 60: minute -= 60 hour += 1 while hour > 24: hour -= 24 day += 1 if change: try: start_time = now - timedelta(days=(year * 365 + day), hours=hour, minutes=minute, seconds=second) except ValueError: pass except OverflowError: pass else: self.state_manager.state = Stopwatch(start_time) else: self.state_manager.state = Stopwatch() elif self.line[-2] == '-': self.state_manager.state = Clock() elif self.line[-2] == 'x': self.shutdown() elif self.line[-2] == 'f': display.toggle_full_screen(self.root_object_manager, self.state_manager) elif self.line[-2] == 'h': self.root_object_manager.hud = None if self.root_object_manager.hud else \ HUD(self.state_manager, self.root_object_manager, self.keyboard_manager, self.handler_manager) elif self.line[-2] == 'c': constants.responsible_color = False if len(self.line) >= 19: constants.change_color( (int(self.line[:2], 16), int( self.line[2:4], 16), int(self.line[4:6], 16)), (int(self.line[6:8], 16), int( self.line[8:10], 16), int(self.line[10:12], 16)), (int(self.line[12:14], 16), int( self.line[14:16], 16), int(self.line[16:18], 16))) self.state_manager.state = Clock() elif len(self.line) >= 3: if ord(self.line[-3].upper()) - ord('G') < len( Color.SAMPLE_PALETTES): constants.change_color( *Color.SAMPLE_PALETTES[ord(self.line[-3].upper()) - ord('G')]) self.state_manager.state = Clock() else: if isinstance(self.state_manager.state, Color): constants.responsible_color = True self.state_manager.state = Clock() else: self.state_manager.state = Color() if self.root_object_manager.hud is not None: self.root_object_manager.hud.recolor_background() elif self.line[-2] == 's': if 'x' in (resolution := self.line[:-2]): width, height = resolution.split('x') width, height = int(width), int(height) display.resize((width, height), self.root_object_manager, self.state_manager, ResizeAlert) else: display.resize((480, 720), self.root_object_manager, self.state_manager, ResizeAlert) elif self.line[-2] == 'o': Timer.PLAY_SOUND = not Timer.PLAY_SOUND if Timer.PLAY_SOUND: play_wav(Timer.END_SOUND) elif self.line.lower().startswith('uuddlrlrab'): self.state_manager.state = EasterEgg() self.line = ''
def __init__(self, master, mens, doubles): """ @type master: Toplevel widget @param master: Main application window. @type mens: integer @param mens: Flag, 0 - women's match, 1 = men's match, 2 = mixed match. @type doubles: boolean @param doubles: Flag, True if this is a doubles match. """ tk.Toplevel.__init__(self, master) self.overrideredirect(1) # No window decorations, no way to close window self.geometry('+100+100') self.numberOfSets = tk.IntVar() self.numberOfSets.set(3) self.doubles = doubles self.player1String = tk.StringVar(self) # First player, team 1, string including all object properties in parseable format self.player2String = tk.StringVar(self) # First player, team 2, string including all object properties in parseable format self.player1aString = tk.StringVar(self) # Second player, team 1, string including all object properties in parseable format self.player2aString = tk.StringVar(self) # Second player, team 2, string including all object properties in parseable format self.duplicateLastName = set([]) if doubles: # Doubles match tk.Radiobutton(self, text="Two sets + tiebreak", padx = 20, variable = self.numberOfSets, value = 2, width = 20, anchor='w').pack() tk.Radiobutton(self, text="Three sets", padx = 20, variable = self.numberOfSets, value = 3, width = 20, anchor='w').pack() elif mens == 1: # Mens singles match tk.Radiobutton(self, text="Three sets", padx = 20, variable = self.numberOfSets, value = 3, width = 20, anchor='w').pack() tk.Radiobutton(self, text="Five sets", padx = 20, variable = self.numberOfSets, value = 5, width = 20, anchor='w').pack() if not doubles: # Singles match if (mens == 0): # Womens singles match # Get list of womens singles players plist = readPlayers(womensSinglesUrl) else: # Mens singles match # Get list of mens singles players plist = readPlayers(mensSinglesUrl) listToCheck = plist self.player1String.set(plist[0]) # default value self.player2String.set(plist[1]) # default value tk.Label(self,text='Player 1').pack() # Get a formatted dropdown menu for player 1 w1 = myDropdown(self,self.player1String,plist) w1.pack() tk.Label(self,text='Player 2').pack() # Get a formatted dropdown menu for player 2 w2 = myDropdown(self,self.player2String,plist) w2.pack() else: # Doubles match if(mens == 0): # Womens doubles match # Get list of womens doubles players plist1 = plist2 = readPlayers(womensDoublesUrl) listToCheck = plist1[:] elif(mens == 1): # Mens doubles match # Get list of mens doubles players plist1 = plist2 = readPlayers(mensDoublesUrl) listToCheck = plist1[:] else: # Mixed doubles match # Get list of womens doubles players plist1 = readPlayers(womensDoublesUrl) # Get list of mens doubles players plist2 = readPlayers(mensDoublesUrl) listToCheck = plist1[:] listToCheck.extend(plist2) self.player1String.set(plist1[0]) # default value self.player2String.set(plist1[2]) # default value self.player1aString.set(plist2[1]) # default value self.player2aString.set(plist2[3]) # default value tk.Label(self, text='Team 1').pack() # Get a formatted dropdown menu for team 1, player 1 w1 = myDropdown(self,self.player1String,plist1) w1.pack() # Get a formatted dropdown menu for team 1, player 2 w1a = myDropdown(self,self.player1aString,plist2) w1a.pack() tk.Label(self, text='Team 2').pack() # Get a formatted dropdown menu for team 2, player 1 w2 = myDropdown(self,self.player2String,plist1) w2.pack() # Get a formatted dropdown menu for team 2, player 2 w2a = myDropdown(self,self.player2aString,plist2) w2a.pack() # Find duplicate last names (used to determine need for first initial) self.duplicateLastName = duplicates(listToCheck) self.startButton = tk.Button(self, text='Start', width=8) self.startButton.pack(side='left') self.title("Match Info #3") # Won't have any effect, given no decorations util.center(self)
def center_y(self): self.y = center(display.size[1], self.height)
def initUI(self): logomap = QPixmap('./image/signin.png') logolbl = QLabel(self) logolbl.setPixmap(logomap) logolbl.setScaledContents(True) # 图片自适应标签大小 title = QLabel('电子投票系统') title.setAlignment(Qt.AlignCenter) title.setFont(QFont("Microsoft YaHei", 15)) user = QLabel('账号: ') pwd = QLabel('密码: ') user = QLabel('账号: ') pwd = QLabel('密码: ') self.userInput = QLineEdit() self.userInput.setPlaceholderText('请输入用户名') self.pwdInput = QLineEdit() self.pwdInput.setPlaceholderText('请输入密码') self.pwdInput.setEchoMode(QLineEdit.Password) #密码不以明文显示 self.loginButton = QPushButton('登录', self) self.loginButton.setIcon(QIcon('./image/start.png')) self.loginButton.clicked.connect(self.onLogin) self.registerButton = QPushButton('注册', self) self.registerButton.setFont(QFont('黑体')) self.registerButton.setIcon(QIcon('./image/register.png')) self.registerButton.clicked.connect(self.onRegister) rightcenterLayout = QGridLayout() rightcenterLayout.addWidget(user, 0, 0, 1, 1) rightcenterLayout.addWidget(pwd, 1, 0, 1, 1) rightcenterLayout.addWidget(self.userInput, 0, 1, 1, 3) rightcenterLayout.addWidget(self.pwdInput, 1, 1, 1, 3) rightcenterFrame = QFrame() rightcenterFrame.setFrameShape(QFrame.WinPanel) rightcenterFrame.setLayout(rightcenterLayout) rightdownLayout = QHBoxLayout() rightdownLayout.addWidget(self.loginButton) rightdownLayout.addWidget(self.registerButton) rightLayout = QVBoxLayout() rightLayout.addWidget(title) rightLayout.addWidget(rightcenterFrame) rightLayout.addLayout(rightdownLayout) totalLayut = QHBoxLayout() totalLayut.addWidget(logolbl) totalLayut.addLayout(rightLayout) self.setLayout(totalLayut) self.resize(480, 200) util.center(self) self.setFont(QFont('宋体', 12)) self.setWindowTitle('登录') self.setWindowIcon(QIcon('./image/car.png'))
def pose_from_motif_tree_old(self, structure, basepairs, motifs, designable): p = pose.Pose() p.designable = designable p.name = "assembled" p.path = "assembled" p.structure = structure p.basepairs = basepairs p.ends = motif_factory.factory._setup_basepair_ends( structure, basepairs) ss = secondary_structure_factory.factory.secondary_structure_from_motif( p) p.secondary_structure = ss p.end_ids = ["" for x in p.ends] for i, end in enumerate(p.ends): res1 = ss.get_residue(uuid=end.res1.uuid) res2 = ss.get_residue(uuid=end.res2.uuid) ss_end = ss.get_bp(res1, res2) p.end_ids[i] = secondary_structure.assign_end_id(ss, ss_end) #update all motifs in pose, make sure that the correct basepairs are used #since basepairs are used to align there are two choices of which basepair to #be used for j, m in enumerate(motifs): bps = [] residue_map = {} for bp in m.basepairs: new_bp = p.get_basepair(bp_uuid=bp.uuid) #print bp.residues(), len(new_bp) if len(new_bp) != 0: bps.append(new_bp[0]) continue best = 1000 best_bp = None for m2 in motifs: if m == m2: continue for end in m2.ends: alt_bp = p.get_basepair(bp_uuid=end.uuid) if len(alt_bp) == 0: continue dist = util.distance(bp.d(), alt_bp[0].d()) if dist < best: best_bp = alt_bp[0] best = dist if best_bp is None: continue new_bp = [best_bp] for r1 in best_bp.residues(): r1_cent = util.center(r1.atoms) best_match = None best_dist = 1000 for r2 in bp.residues(): r2_cent = util.center(r2.atoms) dist = util.distance(r1_cent, r2_cent) if dist < best_dist: best_dist = dist best_match = r2 residue_map[best_match] = r1 bps.append(new_bp[0]) chains = [] #print m.name for c in m.chains(): res = [] for r in c.residues: new_r = p.get_residue(uuid=r.uuid) if new_r is not None: res.append(new_r) elif r in residue_map: res.append(residue_map[r]) else: print r, r.uuid raise ValueError("cannot find residue") chains.append(chain.Chain(res)) if len(bps) != len(m.basepairs): raise ValueError( "something went horribly wrong: did not find all basepairs" ) m_copy = motif.Motif() m_copy.mtype = m.mtype m_copy.name = m.name m_copy.structure.chains = chains m_copy.basepairs = bps m_copy.ends = motif_factory.factory._setup_basepair_ends( m_copy.structure, bps) motif_factory.factory._setup_secondary_structure(m_copy) if m_copy.mtype is not motif_type.HELIX: best_ends = [] best_end_ids = [] for i, end in enumerate(m.ends): best = 1000 best_end = None best_end_id = None for c_end in m_copy.ends: dist = util.distance(end.d(), c_end.d()) if dist < best: best_end = c_end best_end_id = m.end_ids[i] best = dist best_ends.append(best_end) best_end_ids.append(best_end_id) m_copy.ends = best_ends m_copy.end_ids = best_end_ids p.motif_dict[m_copy.mtype].append(m_copy) p.motif_dict[motif_type.ALL].append(m_copy) self._add_secondary_structure_motifs(p) self.standardize_pose(p) return p