def __init__(self, master): Panel.__init__(self, master, frameText="Range Selection") self.RangesVars = {} self.RangesCB = {} self.RangesFunctions = {} self.widgetCreation()
def __init__(self, **kwargs): if not kwargs.has_key("CellFormatter"): kwargs["CellFormatter"] = CellFormatter(self) if not kwargs.has_key("RowFormatter"): kwargs["RowFormatter"] = RowFormatter(self) self.tableListeners = [] self.widgetMap = {} if kwargs.has_key("Element"): self.tableElem = kwargs.pop("Element") fc = DOM.getFirstChild(self.tableElem) if fc: self.bodyElem = fc else: self.bodyElem = DOM.createTBody() DOM.appendChild(self.tableElem, self.bodyElem) else: self.tableElem = DOM.createTable() self.bodyElem = DOM.createTBody() DOM.appendChild(self.tableElem, self.bodyElem) self.setElement(self.tableElem) self.sinkEvents(Event.ONCLICK) Panel.__init__(self, **kwargs)
def __init__(self, master): Panel.__init__(self, master, frameText="Violation state Selection") self.ViolationsVars = {} self.ViolatedCB = {} self.cutOff = Tk.DoubleVar(self) self.widgetCreation()
def __init__(self, **kwargs): if not kwargs.has_key('CellFormatter'): kwargs['CellFormatter'] = CellFormatter(self) if not kwargs.has_key('RowFormatter'): kwargs['RowFormatter'] = RowFormatter(self) self.tableListeners = [] self.widgetMap = {} if kwargs.has_key('Element'): self.tableElem = kwargs.pop('Element') fc = DOM.getFirstChild(self.tableElem) if fc: self.bodyElem = fc else: self.bodyElem = DOM.createTBody() DOM.appendChild(self.tableElem, self.bodyElem) else: self.tableElem = DOM.createTable() self.bodyElem = DOM.createTBody() DOM.appendChild(self.tableElem, self.bodyElem) self.setElement(self.tableElem) self.sinkEvents(Event.ONCLICK) Panel.__init__(self, **kwargs)
def get_name(): config.PlayerName = '' name = '' namepanel = Panel(0, 0, config.window_width, config.window_height) while True: namepanel.clear config.gamewindow.clear namepanel.write(config.window_width / 2 - 21, int(config.window_height * .2), 'Please Enter a Name! (ten character limit)') namepanel.write(config.window_width / 2 - len(name) / 2 - 2, int(config.window_height * .3), '( ' + name + ' )') namepanel.blit() config.gamewindow.flush key = libtcodpy.console_wait_for_keypress(True) if key.vk == libtcodpy.KEY_BACKSPACE and len(name) > 0: name = name[:-1] elif key.vk == libtcodpy.KEY_ENTER and len(name) > 0: option = None while option is None: option = Menu('Is ' + name + ' the name you want?', ['Yes', 'No'], 20) if option == 0: break else: if len(name) < 10: if key.c != 0: key_char = chr(key.c) name += key_char config.PlayerName = name
def Menu(header, options, width): if len(options) > 26: raise ValueError('Cannot have a menu with more than 26 options') header_height = libtcodpy.console_get_height_rect(0, 0, 0, config.window_width, config.window_height, header) if header == '': header_height = 0 height = len(options) + header_height menupanel = Panel(0, 0, width, height) menupanel.write_wrap_ex(0, 0, width, height, header, libtcodpy.LEFT) y = header_height letter_index = ord('a') for option_text in options: text = '(' + chr(letter_index) + ') ' + option_text menupanel.write(0, y, text) y += 1 letter_index += 1 x = config.window_width / 2 - width / 2 y = config.window_height / 2 - height / 2 menupanel.blit(xdst=x, ydst=y, bfade=0.7) config.gamewindow.flush key = libtcodpy.console_wait_for_keypress(True) if key.vk == libtcodpy.KEY_ENTER and key.lalt: libtcodpy.console_set_fullscreen(not libtcodpy.console_is_fullscreen()) index = key.c - ord('a') if index >= 0 and index < len(options): return index return None
def __init__(self, mainElem, splitElem, headElem, tailElem, **kwargs): """ Initializes the split panel. @param mainElem the root element for the split panel @param splitElem the element that acts as the splitter @param headElem the element to contain the top or left most widget @param tailElem the element to contain the bottom or right most widget """ self.widgets = [None, None] self.elements = [headElem, tailElem] self.isResizing = False self.setElement(mainElem) self.splitElem = splitElem Panel.__init__(self, **kwargs) self.sinkEvents(Event.MOUSEEVENTS)
def __init__(self, url, season, event, discipline, segment, panel_url): self.url = url # url to scores self.season = season self.event = event self.discipline = discipline self.type = segment self.name = discipline.name + '_' + segment.name self.panel = Panel(panel_url, self.season, self.event, self.discipline, self) self.scorecards = [] # Associated file names and paths. self.fname = discipline.name + '_' + segment.name self.pdf_fname = self.fname + '.pdf' self.csv_fname = self.fname + '.csv' self.parsed_csv_fname = self.fname + '_parsed.csv' self.fpath = get_fpath(season, event, self.pdf_fname) self.csv_path = get_fpath(season, event, self.csv_fname) self.parsed_csv_fpath = get_fpath(season, event, self.parsed_csv_fname) self.directory = get_fpath(self.season, self.event, self.name)
def main(): pygame.init() screen = get_screen() # objects state = State() panel = Panel(screen, state) listeners = panel.listener pygame.display.set_caption("Frank-Hertz Experiment Simulation") while True: screen.fill((100, 170, 220)) panel.update() for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit() for listener in listeners: listener(event) pygame.display.flip()
def __init__(self, mainElem, splitElem, headElem, tailElem, **kwargs): """ Initializes the split panel. @param mainElem the root element for the split panel @param splitElem the element that acts as the splitter @param headElem the element to contain the top or left most widget @param tailElem the element to contain the bottom or right most widget """ self.widgets = [None, None] self.elements = [headElem, tailElem] self.isResizing = False self.setElement(mainElem) self.splitElem = splitElem if not kwargs.has_key('ThumbImage'): kwargs['ThumbImage'] = "splitPanelThumb.png" Panel.__init__(self, **kwargs) self.sinkEvents(Event.MOUSEEVENTS)
def _load_annotation_label_iphotodraw(self, iphotodraw_path): """ Load label annotation from iphotodraw formatted file :param iphotodraw_path: :return: """ # create element tree object tree = ET.parse(iphotodraw_path) # get root element root = tree.getroot() shape_items = root.findall('./Layers/Layer/Shapes/Shape') # Read All Label Items label_items = [] for shape_item in shape_items: text_item = shape_item.find('./BlockText/Text') text = text_item.text.lower() if text.startswith('label'): label_items.append(shape_item) # Form individual panels panels = [] for label_item in label_items: text_item = label_item.find('./BlockText/Text') label = text_item.text words = label.split(' ') if len(words) is not 2: raise Exception(iphotodraw_path + ' ' + label + ' panel is not correct') label = words[1] extent_item = label_item.find('./Data/Extent') height = extent_item.get('Height') width = extent_item.get('Width') x = extent_item.get('X') y = extent_item.get('Y') label_rect = [ round(float(x)), round(float(y)), round(float(width)), round(float(height)) ] panel = Panel(label, None, label_rect) panels.append(panel) self.panels = panels
def main(): dialog = Dialog() panel = Panel() ok = Button("Ok") cancel = Button("Cancel") panel.add_children(ok) panel.add_children(cancel) dialog.add_children(panel) ok.show_help()
def _load_annotation_panel_iphotodraw(self, iphotodraw_path): """ Load panel annotation from iphotodraw formatted file :param iphotodraw_path: :return: """ # create element tree object tree = ET.parse(iphotodraw_path) # get root element root = tree.getroot() shape_items = root.findall('./Layers/Layer/Shapes/Shape') # Read All Label Items panel_items = [] for shape_item in shape_items: text_item = shape_item.find('./BlockText/Text') text = text_item.text.lower() if text.startswith('panel'): panel_items.append(shape_item) # Form individual panels panels = [] for panel_item in panel_items: text_item = panel_item.find('./BlockText/Text') label = text_item.text extent_item = panel_item.find('./Data/Extent') height = extent_item.get('Height') width = extent_item.get('Width') x = extent_item.get('X') y = extent_item.get('Y') panel_rect = [ round(float(x)), round(float(y)), round(float(width)), round(float(height)) ] panel = Panel(label, panel_rect, None) panels.append(panel) self.panels = panels
def main(): root = Tk() panel = Panel() width = 0 heigth = 420 parent = create_main_node(panel, Coordinate(x=0, y=0), "i", heigth) r = parent dic = { ("1", "1"), ("1", "0"), ("1", "0"), } for x in range(2, len(dic) + 1): item = "111" r = create_node(panel, r, item[:x], (list(item[x - 1:]))[0]) final = create_main_node(panel, r, "111", heigth, "") #node_to_node(panel, final, parent, 1) width = final.x width += 50 root.geometry(str(width) + "x" + str(heigth) + "+300+300") root.mainloop()
def __init__(self, x_pos, y_pos): Panel.__init__(self, x_pos, y_pos)
def __init__(self, maker_menu): Panel.__init__(self, maker_menu) self.terrain_selection = DEFAULT_TERRAIN
def _load_annotation_panel_and_label_iphotodraw(self, iphotodraw_path): """ Load both panel and label annotation from iphotodraw formatted file :param iphotodraw_path: :return: """ # create element tree object tree = ET.parse(iphotodraw_path) # get root element root = tree.getroot() shape_items = root.findall('./Layers/Layer/Shapes/Shape') # Read All Items (Panels and Labels) panel_items = [] label_items = [] for shape_item in shape_items: text_item = shape_item.find('./BlockText/Text') text = text_item.text.lower() if text.startswith('panel'): panel_items.append(shape_item) elif text.startswith('label'): label_items.append(shape_item) # Form individual panels panels = [] for panel_item in panel_items: text_item = panel_item.find('./BlockText/Text') label = text_item.text words = label.split(' ') if len(words) is not 2: raise Exception(iphotodraw_path + ' ' + label + ' panel is not correct') label = words[1] extent_item = panel_item.find('./Data/Extent') height = extent_item.get('Height') width = extent_item.get('Width') x = extent_item.get('X') y = extent_item.get('Y') panel_rect = [round(float(x)), round(float(y)), round(float(width)), round(float(height))] panel = Panel(label, panel_rect, None) panels.append(panel) # Fill in label rects for panel in panels: for label_item in label_items: text_item = label_item.find('./BlockText/Text') label = text_item.text words = label.split(' ') if len(words) is not 2: raise Exception(iphotodraw_path + ' ' + label + ' label is not correct') label = words[1] if label.lower() == panel.label.lower(): extent_item = label_item.find('./Data/Extent') height = extent_item.get('Height') width = extent_item.get('Width') x = extent_item.get('X') y = extent_item.get('Y') label_rect = [round(float(x)), round(float(y)), round(float(width)), round(float(height))] panel.label_rect = label_rect self.panels = panels
def __init__(self, master): Panel.__init__(self, master, frameText="NOE density Preferences") self.gradient = Tk.StringVar(self) self.widgetCreation()
from Panel import Panel import time import random p = Panel() i = 0 while True: if (i < 10): p.setBackground((0,0,0)) p.show() p.setBackground((0,100,0)) p.show() i = i+1 #time.sleep(1)
image_viewer = ImageViewer() video.VideoSignal.connect(image_viewer.setImage) button_layout = QVBoxLayout() start_button = QPushButton('Start') start_button.clicked.connect(video.startVideo) button_layout.addWidget(start_button) image_layout = QVBoxLayout() image_layout.addWidget(image_viewer) panel_layout = QVBoxLayout() panel = Panel() #thread2 = QThread() #panel.moveToThread(thread2) #thread2.start() canvas_viewer = ImageViewer() panel.ImageSignal.connect(canvas_viewer.setImage) panel_layout.addWidget(canvas_viewer) red_button = QPushButton('red') red_button.clicked.connect(panel.changeRed) green_button = QPushButton('green') green_button.clicked.connect(panel.changeGreen) blue_button = QPushButton('blue')
from Panel import Panel from Square import Square import time import random from Disperse import Disperse p = Panel() d = Disperse(p) squares = [] for i in range(10): temp = Square(5,5,(255,0,0),p) temp.x = random.randint(0, p.width) temp.y = random.randint(0, p.height) temp.col = (random.randint(0,255),random.randint(0,255),random.randint(0,255)) squares.append(temp) stamp = p.getMillis() fRate = 60.0 while True: if (p.getMillis() - stamp > (1/fRate) * 1000): p.setBackground((0,0,0)) for square in squares: square.update() square.show() #d.update() p.show() stamp = p.getMillis()
def End_Game(finished=False): header = '' PC = CM.get_Component('Creature', config.PlayerId) PL = CM.get_Component('Level', config.PlayerId) PA = CM.get_Component('Attack', config.PlayerAttack) if finished: header = '\n\nYou completed the dungeon! Congradulations ' + \ config.PlayerName else: header = '\n\nSadly you died in the dungeon. ' +\ 'Better luck next time ' + \ config.PlayerId header += '\n\nDungeon Level: ' + str(config.CurrentDungeonLevel) + \ '\nLevel: ' + str(PL.level) + \ ' Max Hp: ' + str(PC.MaxHp) + \ ' Defense: ' + str(PC.Defense) + \ ' Strength: ' + str(PC.Strength) + \ ' Agility: ' + str(PC.Agility) + '\n' statlst = [] atcklst = [] atcklst.append('Attack: ' + str(PA.Dice) + 'd' + str(PA.Sides)) if 'LifeDrain' in PA.Special: atcklst.append(' Life Drain: ' + str(PA.Special['LifeDrain'])) if 'Paralyze' in PA.Special: atcklst.append(' Paralyze: %' + str(PA.Special['Paralyze'])) if 'PierceDefense' in PA.Special: atcklst.append(' Pierce Defense: %' + str(PA.Special['PierceDefense'])) if 'CausePoison' in PA.Special: (percent, turns, damage) = PA.Special['CausePoison'] atcklst.append(' Poison: %' + str(percent) + ' T' + str(turns) + ' D' + str(damage)) if 'EnhancedDefense' in PC.Special: statlst.append(' Enhanced Defense: %' + str(PC.Special['EnhancedDefense'])) if 'SideSwipe' in PC.Special: statlst.append(' Side Swipe Attack') if 'Dodge' in PC.Special: statlst.append(' Dodge: %' + str(PC.Special['Dodge'])) if 'ParalyzeResistance' in PC.Special: statlst.append(' Paralyze Resistance: %' + str(PC.Special['ParalyzeResistance'])) if 'CritChance' in PC.Special: statlst.append(' Crit Chance: %' + str(PC.Special['CritChance'])) if 'ReduceCrit' in PC.Special: statlst.append(' Reduce Crit: %' + str(PC.Special['ReduceCrit'])) if 'Fear' in PC.Special: statlst.append(' Fear: %' + str(PC.Special['Fear'])) if 'RandomBlink' in PC.Special: statlst.append(' Blink Uses: ' + str(PC.Special['RandomBlink'])) if 'HealthPotion' in PC.Special: statlst.append(' Health Potions: ' + str(PC.Special['HealthPotion'])) if 'LifeSaver' in PC.Special: statlst.append(' %$#: @') if 'CardinalLeap' in PC.Special: (need, current, distance) = PC.Special['CardinalLeap'] statlst.append(' Leap: E' + str(need) + ' Dist' + str(distance)) for item in atcklst: header += item header += '\n\n' cur = 1 for item in statlst: if cur < 3: cur += 1 header += item else: cur = 1 header += item + '\n' if cur != 1: header += '\n' width = config.window_width options = ['Main Menu', 'Quit'] header_height = libtcodpy.console_get_height_rect(0, 0, 0, config.window_width, config.window_height, header) height = len(options) + header_height endpanel = Panel(0, 0, width, height) endpanel.write_wrap_ex(0, 0, width, height, header, libtcodpy.LEFT) y = header_height letter_index = ord('a') for option_text in options: text = '(' + chr(letter_index) + ') ' + option_text endpanel.write(0, y, text) y += 1 letter_index += 1 x = config.window_width / 2 - width / 2 y = config.window_height / 2 - height / 2 endpanel.blit(xdst=x, ydst=y, bfade=0.7) config.gamewindow.flush filename = config.PlayerName keepcharacters = (' ', '.', '_') filename = "".join( c for c in filename if c.isalnum() or c in keepcharacters).rstrip() if filename == '': filename = 'Empty' if finished: filename += '\'s Victory Monument' else: filename += '\'s Tombstone' with open(filename + '.txt', mode='w') as f: f.write(header) choice = None while choice is None: key = libtcodpy.console_wait_for_keypress(True) if key.vk == libtcodpy.KEY_ENTER and key.lalt: libtcodpy.console_set_fullscreen( not libtcodpy.console_is_fullscreen()) index = key.c - ord('a') if index >= 0 and index < len(options): choice = index if choice == 0: config.game_state = 'finished' elif choice == 1: config.game_state = 'Quit'
w = int(input("Please enter the horizontal resolution of your screen: ")) h = int(input("Please enter the vertical resolution of your screen: ")) print(f"The program should have started with a window size of {w} x {h}") print( "If the program window is not fully visible then please enter a larger resolution, else change the resolution of your screen" ) w = w - 400 h = h - 60 hor, ver, panelHor = w, h, 375 grid_size = 25 pygame.display.set_caption("Graph Search Visualizer") pygame.display.set_icon(pygame.image.load("icon.png")) canvas = pygame.Surface((hor, ver)) # panelSurf = pygame.Surface((panelHor - grid_size, ver - grid_size*2)) panel = Panel(hor + grid_size // 2, grid_size // 2, panelHor - grid_size, ver - grid_size, (164, 250, 107)) screen = pygame.display.set_mode((hor + panelHor, ver)) #> Colors panelColor = (164, 250, 107) #(136, 248, 71) #> Buttons g = Graph(canvas, screen, 25, False) Button.surfaceX = hor + grid_size // 2 Button.surfaceY = grid_size // 2 def draw_grid(width, length, size): grid_surf = pygame.Surface((width, length)) grid_surf.set_colorkey((0, 0, 0)) for hor in range(length // size):
def __init__(self, master): Panel.__init__(self, master, frameText="NOE Sticks Preferences") self.radius = Tk.DoubleVar(self) self.colors = {} self.widgetCreation()
def __init__(self, master): Panel.__init__(self, master, frameText="Constraints Selection") self.panelsList = [] self.widgetCreation()
def __init__(self, master): Panel.__init__(self, master, frameText="Structure") self.residueRanges = Tk.StringVar(self) self.widgetCreation()
def panel(parentWindow, **kwds): from Panel import Panel return Panel(parentWindow, **kwds)
def __init__(self, root, main_menu): self.saves = MapList() if self.saves.get_size(): self.set_map(self.saves.peek()) Panel.__init__(self, root, main_menu)
def __init__(self, master): Panel.__init__(self, master, frameText="NOE Preferences") self.panelsList=[] self.widgetCreation()
from Panel import Panel from Square import Square from Square import BouncingSquares import time import random from Disperse import Disperse from Scene import Scene from SceneManager import SceneManager from ImgSizer import ImgSizer from SinWave import SinWave from ColorLerp import ColorLerp from GifPlayer import GifPlayer p = Panel() sceneManager = SceneManager() # sceneManager.addScene(Scene(ColorLerp(0.05,p), 40)) # sceneManager.addScene(Scene(Disperse(10,p), 14, True)) # sceneManager.addScene(Scene(ImgSizer("tree.png", p), 25)) # sceneManager.addScene(Scene(Disperse(10,p), 14, True)) # sceneManager.addScene(Scene(ImgSizer("RoughDong.png", p), 10)) # sceneManager.addScene(Scene(Disperse(10,p), 14, True)) # sceneManager.addScene(Scene(ImgSizer("Mario.png", p), 30)) # sceneManager.addScene(Scene(Disperse(10,p), 14, True)) # sceneManager.addScene(Scene(SinWave(p), 35)) # sceneManager.addScene(Scene(Disperse(10,p), 30, True)) # sceneManager.addScene(Scene(BouncingSquares(4,4,10,p), 30)) # sceneManager.addScene(Scene(Disperse(10,p), 14, True)) # sceneManager.addScene(Scene(BouncingSquares(3,3,20,p), 30)) # sceneManager.addScene(Scene(Disperse(10,p), 14, True)) # sceneManager.addScene(Scene(BouncingSquares(1,1,200,p), 30)) # sceneManager.addScene(Scene(Disperse(10,p), 14, True))
def __init__(self, Element=None, **kwargs): if Element is None: Element = DOM.createDiv() self.setElement(Element) Panel.__init__(self, **kwargs)
import smbus import time import urllib.request from ServerConnector import Connector from Panel import Panel bus = smbus.SMBus(1) ADDR = 0x04 WHITE_PIXEL = [0x1, 0x1, 0x1] BLACK_PIXEL = [0x0, 0x0, 0x0] panel1 = Panel(bus, 0x04) #panel2 = Panel(bus, 0x05) panels = [[panel1]] color_grid = [[0 for x in range(15)] for y in range(15)] color_grid[0][0] = [[[0 for x in range(3)] for y in range(32)] for z in range(32)] color_grid[0][1] = [[[0 for x in range(3)] for y in range(32)] for z in range(32)] #panel.fill_rect([0,0], [32,32], WHITE_PIXEL) connector = Connector("http://pathealy.pythonanywhere.com/get_grid") ticks = 0 ticked = False wait_flag = False
def initPanels(self): print("Initialising the 4 panels\n ") # init all 4 panels with their walls self.panel1 = Panel( [[Case() for i in range(int(globals.sizeOfPanel))] for j in range(int(globals.sizeOfPanel))]) self.panel2 = Panel( [[Case() for i in range(int(globals.sizeOfPanel))] for j in range(int(globals.sizeOfPanel))]) self.panel3 = Panel( [[Case() for i in range(int(globals.sizeOfPanel))] for j in range(int(globals.sizeOfPanel))]) self.panel4 = Panel( [[Case() for i in range(int(globals.sizeOfPanel))] for j in range(int(globals.sizeOfPanel))]) # init panel4's walls self.panel4.tabCase[1][4].target = 9 self.panel4.tabCase[2][6].target = 11 self.panel4.tabCase[5][1].target = 13 self.panel4.tabCase[6][3].target = 15 self.panel4.tabCase[6][3].down = 1 self.panel4.tabCase[6][3].right = 1 self.panel4.tabCase[7][4].right = 1 self.panel4.tabCase[2][0].down = 1 self.panel4.tabCase[1][3].right = 1 self.panel4.tabCase[1][4].down = 1 self.panel4.tabCase[4][1].down = 1 self.panel4.tabCase[5][1].right = 1 self.panel4.tabCase[1][6].down = 1 self.panel4.tabCase[2][6].left = 1 self.panel4.tabCase[7][5].left = 1 self.panel4.tabCase[3][7].down = 1 self.panel4.tabCase[4][7].right = 1 # init panel3's walls self.panel3.tabCase[1][5].target = 10 self.panel3.tabCase[3][1].target = 12 self.panel3.tabCase[5][6].target = 14 self.panel3.tabCase[6][2].target = 16 self.panel3.tabCase[3][1].right = 1 self.panel3.tabCase[3][1].down = 1 self.panel3.tabCase[1][5].down = 1 self.panel3.tabCase[1][5].left = 1 self.panel3.tabCase[3][7].down = 1 self.panel3.tabCase[5][6].right = 1 self.panel3.tabCase[5][6].up = 1 self.panel3.tabCase[6][2].up = 1 self.panel3.tabCase[6][2].left = 1 self.panel3.tabCase[7][3].right = 1 # init panel2's walls self.panel2.tabCase[1][5].target = 1 self.panel2.tabCase[3][1].target = 3 self.panel2.tabCase[4][6].target = 5 self.panel2.tabCase[6][4].target = 8 self.panel2.tabCase[0][1].right = 1 self.panel2.tabCase[1][5].right = 1 self.panel2.tabCase[1][5].down = 1 self.panel2.tabCase[1][7].down = 1 self.panel2.tabCase[3][1].up = 1 self.panel2.tabCase[3][1].left = 1 self.panel2.tabCase[4][6].right = 1 self.panel2.tabCase[4][6].up = 1 self.panel2.tabCase[6][4].down = 1 self.panel2.tabCase[6][4].left = 1 # init panel1's walls self.panel1.tabCase[2][5].target = 2 self.panel1.tabCase[4][2].target = 4 self.panel1.tabCase[5][7].target = 6 self.panel1.tabCase[6][1].target = 7 self.panel1.tabCase[0][3].right = 1 self.panel1.tabCase[2][5].right = 1 self.panel1.tabCase[2][5].down = 1 self.panel1.tabCase[4][2].right = 1 self.panel1.tabCase[4][2].up = 1 self.panel1.tabCase[5][7].left = 1 self.panel1.tabCase[5][7].down = 1 self.panel1.tabCase[4][0].down = 1 self.panel1.tabCase[6][1].up = 1 self.panel1.tabCase[6][1].left = 1 '''
def __init__(self, master): Panel.__init__(self, master, frameText="NOE Representation") self.widgetCreation() self.mainApp = "" #Must be set at run time self.NMRCommands = "" #Must be set by application at run time
def __init__(self, master): Panel.__init__(self, master, frameText="Constraints Files") self.widgetCreation() self.NMRCommands = "" #Must be set by application at run time
# Author: Taishi Matsumura # Created: 2016-07-26 # # Copyright (C) 2016 Taishi Matsumura # from Neuron import Neuron from Panel import Panel, IstepSlider from matplotlib.pyplot import close, figure, subplots_adjust close('all') neuron = Neuron(1) fig = figure() subplots_adjust(left=0.15, bottom=0.25) sl = IstepSlider() Vm_panel = Panel(211, neuron.get_t(), neuron.get_V(), ylabel='Vm [mV]', ylim=(-80, 50)) Gates_panel = Panel(413, neuron.get_t(), neuron.get_m(), ylabel='Gate vars [-]') Istep_panel = Panel(414, neuron.get_t(), sl.get_value(), ylabel='Istep [uA]', ylim=(sl.minval, sl.maxval)) fig.add_axes(sl.position) fig.add_subplot(Vm_panel.getPanel()) fig.add_subplot(Gates_panel.getPanel()) fig.add_subplot(Istep_panel.getPanel()) # ---------------------------------------------------------------------------- # Main loop # ---------------------------------------------------------------------------- while True: I = sl.get_value() neuron.update(I) # ----------------------------------------------------------------------------
px = cursor.x pw = xbox - cursor.x + 1 else: px = xbox pw = cursor.x - xbox + 1 if cursor.y < ybox: py = cursor.y ph = ybox - cursor.y + 1 else: py = ybox ph = cursor.y - ybox + 1 boxlist[-1] = Panel(px, py, pw, ph, border=True) test = Console(80, 50, 'test') test3 = Panel(0, 0, 80, 50) test3.write(0, 0, '1234567891111111111222222222233333333334444444444' + '5555555555666666666677777777778') test3.write(0, 1, ' 0123456789012345678901234567890123456789' + '0123456789012345678901234567890') test3.write_wrap(0, 0, 2, 50, '1 2 3 4 5 6 7 8 9 1011121314151617181' + '92021222324252627282930313233343536373839404142434' + '4454647484950') cursor = Panel(0, 0, 1, 1) cursor.write(0, 0, '@') boxlist = [] xbox = 0 ybox = 0 working = False mouse = libtcodpy.Mouse() key = libtcodpy.Key()
def menu(header, options, width): if len(options) > 26: raise ValueError('Cannot have a menu with more than 26 options') # header_height = libtcod.console_get_height_rect(con, 0, 0, width, # SCREEN_HEIGHT, header) header_height = libtcod.console_get_height_rect(console.body, 0, 0, width, SCREEN_HEIGHT, header) if header == '': header_height = 0 height = len(options) + header_height # window = libtcod.console_new(width, height) window = Panel(0, 0, width, height) # libtcod.console_set_default_foreground(window, libtcod.white) # libtcod.console_print_rect_ex(window, 0, 0, width, height, # libtcod.BKGND_NONE, libtcod.LEFT, header) window.set_default_foreground(libtcod.white) window.write_wrap_ex(0, 0, width, height, header, libtcod.LEFT) y = header_height letter_index = ord('a') for option_text in options: text = '(' + chr(letter_index) + ') ' + option_text # libtcod.console_print_ex(window, 0, y, libtcod.BKGND_NONE, # libtcod.LEFT, text) window.write(0, y, text) y += 1 letter_index += 1 x = SCREEN_WIDTH / 2 - width / 2 y = SCREEN_HEIGHT / 2 - height / 2 # libtcod.console_blit(window, 0, 0, width, height, 0, x, y, 1.0, 0.7) window.x = x window.y = y window.blit(bfade=0.7) # libtcod.console_flush() root.flush key = libtcod.console_wait_for_keypress(True) if key.vk == libtcod.KEY_ENTER and key.lalt: libtcod.console_set_fullscreen(not libtcod.console_is_fullscreen()) index = key.c - ord('a') if index >= 0 and index < len(options): return index return None
class Segment: skater_re = re.compile('(\d+)\s*' + # rank '(\D+ \D+?)\s*' + # skater name '([A-Z][A-Z][A-Z])\s*' + # country '([12345]?\d)?\s+' + # starting number '(\d\d\d?\.\d\d)\s*' + # total score points + '\s+' + # tes points + '\s*' + # pcs '(-?\d.\d\d)') # deductions tes_re = re.compile('^\s*' + base_value_re + # total base value points + '\s*$') # total tes deduction_re = re.compile('[^-\d\s:()]+:?\s+-?[1-9]\.\d\d') # pcs_re = re.compile('Program\s+Component\D*' + points) def __init__(self, url, season, event, discipline, segment, panel_url): self.url = url # url to scores self.season = season self.event = event self.discipline = discipline self.type = segment self.name = discipline.name + '_' + segment.name self.panel = Panel(panel_url, self.season, self.event, self.discipline, self) self.scorecards = [] # Associated file names and paths. self.fname = discipline.name + '_' + segment.name self.pdf_fname = self.fname + '.pdf' self.csv_fname = self.fname + '.csv' self.parsed_csv_fname = self.fname + '_parsed.csv' self.fpath = get_fpath(season, event, self.pdf_fname) self.csv_path = get_fpath(season, event, self.csv_fname) self.parsed_csv_fpath = get_fpath(season, event, self.parsed_csv_fname) self.directory = get_fpath(self.season, self.event, self.name) def __repr__(self): return self.event.name + ' ' + self.name def get_page(self): get_page(self.url, self.season, self.event, self.pdf_fname) self.panel.get_page() def get_raw_csv_rows(self): rows = [] with open(self.csv_path, 'rb') as f: reader = csv.reader(f) for row in reader: rows.append(' '.join(row)) return rows def parse_raw_csv(self): if self._load_gpcan05_pairs_short(): return assert not self.scorecards num_judges = str(self.num_judges) self.elt_re = re.compile('(\d\d?)\s+' + # element order '(\S+)\s+' + # element name '(\D*?)\s*' + # info (i.e. UR) base_value_re + # base value '((?:x|X)?)\s*' + # bonus marker '(-?\d.\d\d)\s*' + # goe '((?:(?:-?\d|-)\s*){' + num_judges + '})\s*' + # goes '([0-]\s*)*\s*' # extra judges...? '(\d?\d.\d\d)') # element score self.component_re = re.compile( '(\D+)\s*' + # component name '(\d.\d\d)\s*' + # factor '((?:(?:\d?\d.\d\d|-)\s+){' + num_judges + '})\s*' + # judges marks '(?:(?:-|0.00)\s*)*\s*' # extra judges...? '(\d?\d.\d\d)') # aggregated judges marks rows = self.get_raw_csv_rows() skater = None scorecard = None self.mistakes = [] for line in rows: line = line.strip() line = self._remove_info(line) skater_match = self.skater_re.match(line) elt_match = self.elt_re.match(line) component_match = self.component_re.match(line) # Skater + summary info. if skater_match: if scorecard: self.mistakes += scorecard.check_total() self.scorecards.append(scorecard) scorecard = None skater_info = {} for i, info in enumerate( ('rank', 'name', 'country', 'starting_number', 'total_score', 'tes', 'pcs', 'deductions')): skater_info[info] = skater_match.group(i + 1) skater = Skater(skater_info['name'], skater_info['country'], self.discipline) scorecard = Scorecard(self.url, self.season, self.event, self.discipline, self, skater, skater_info['rank'], skater_info['starting_number'], skater_info['total_score'], skater_info['tes'], skater_info['pcs'], skater_info['deductions']) continue # A technical element. elif elt_match: scorecard.add_element(elt_match) # The TES summary row. elif scorecard and scorecard.elements and self.tes_re.match(line): scorecard.aggregate_elements(self.tes_re.match(line)) # A PCS line. elif component_match: scorecard.add_component(component_match) # Bottom of the scorecard, either PCS summary or deductions. elif scorecard and scorecard.components: if 'Program Component' in line: scorecard.aggregate_pcs(line[-5:]) else: scorecard.add_deduction(self.deduction_re.findall(line)) if scorecard: self.mistakes += scorecard.check_total() self.scorecards.append(scorecard) if self.mistakes: print self for mistake in self.mistakes: print mistake print def write_to_csv(self): if self._load_gpcan05_pairs_short(): return if not self.scorecards: self.parse_raw_csv() clear_and_make_dir(self.directory) judge_numbers = list(xrange(1, self.num_judges + 1)) judge_space = ['' for _ in xrange(self.num_judges)] for scorecard in self.scorecards: fname = '{0}/{1}_{2}.csv'.format( self.directory, scorecard.rank, scorecard.skater.name.replace(' / ', '_').replace(' ', '_')) with open(fname, 'w') as csvfile: writer = csv.writer(csvfile) writer.writerow([self.num_judges]) writer.writerow([ 'Rank', 'Name', 'Nation', 'Starting Number', 'Total Segment Score', 'Total Element Score', 'Total Program Component Score (factored)', 'Total Deductions' ]) writer.writerow([ scorecard.rank, scorecard.skater.name, scorecard.skater.country, scorecard.starting_number, scorecard.total_score, scorecard.tes, scorecard.pcs, scorecard.total_deductions ]) # Write technical scores. writer.writerow([ '#', 'Executed Elements', 'Info', 'Base Value', 'Bonus', 'GOE' ] + judge_numbers + ['Ref', 'Scores of Panel']) for elt in scorecard.elements: writer.writerow([ elt.number, elt.name, elt.info, elt.base_value, elt.bonus, elt.goe ] + elt.goes + ['', elt.points]) writer.writerow(['', '', '', scorecard.base_value, '', ''] + judge_space + ['', scorecard.tes]) # Write component scores. writer.writerow( ['', 'Program Components', '', '', '', 'Factor']) for comp in scorecard.components: writer.writerow(['', comp.name, '', '', '', comp.factor] + comp.scores + ['', comp.points]) writer.writerow(['', '', '', '', '', ''] + judge_space + ['', scorecard.pcs]) for reason, value in scorecard.deductions.iteritems(): writer.writerow(['Deduction', reason, value]) # Rank, Name, Nation, Starting Number, Total Score, TES, PCS, Total Deductions # Number, Executed Elements, Info, Base Value, Bonus, GOE, 1 - num_judges, ref, score # PCS, Component Name, empty, empty, Factor, 1 - num_judges, empty, score # Deduction: point value def read_from_csv(self): if not os.path.isdir(self.directory): self.write_to_csv() return for fname in os.listdir(self.directory): with open(self.directory + '/' + fname) as csvfile: reader = csv.reader(csvfile) num_judges = int(reader.next()[0]) reader.next() # Skip labels row rank, name, nation, starting_number, total_score, tes, pcs, total_deductions = reader.next( ) skater = Skater(name.strip(), nation, self.discipline) scorecard = Scorecard(self.url, self.season, self.event, self.discipline, self, skater, rank, starting_number, total_score, tes, pcs, total_deductions) reader.next() # Skip elements label row elt_row = reader.next() while elt_row[0].isdigit(): number = int(elt_row[0]) name = elt_row[1] info = elt_row[2] base_value = float_of(elt_row[3]) if elt_row[4].lower() == 'true': bonus = True elif elt_row[4].lower() == 'false': bonus = False else: print skater, number, self, elt_row[4] goe = float_of(elt_row[5]) goes = [] parsed_goes = [] for mark in elt_row[6:6 + self.num_judges]: if mark == '-': goes.append(mark) else: goes.append(float_of(mark)) parsed_goes.append(float_of(mark)) points = float_of(elt_row[-1]) scorecard.elements.append( Element(number, name, info, base_value, bonus, goe, goes, parsed_goes, points)) elt_row = reader.next() scorecard.base_value = float_of(elt_row[3]) scorecard.tes = float_of(elt_row[-1]) reader.next() # Skip PCS label row comp_row = reader.next() while comp_row[1]: name = comp_row[1] factor = float_of(comp_row[5]) scores = [] parsed_scores = [] for score in comp_row[6:6 + self.num_judges]: if score == '-': scores.append(score) else: scores.append(float_of(score)) parsed_scores.append(float_of(score)) points = float_of(comp_row[-1]) scorecard.components.append( ProgramComponent(name.strip(), factor, scores, parsed_scores, points)) comp_row = reader.next() scorecard.pcs = float_of(comp_row[-1]) for deduction_row in reader: _, reason, value = deduction_row scorecard.deductions[reason] = float_of(value) self.scorecards.append(scorecard) self.scorecards.sort(key=lambda scorecard: scorecard.rank) @staticmethod def _remove_info(line): """In 2008-2010, many events (see gpjpn2007 pairs short) have the 'Info' keyword in the wrong row (in an element row).""" if line[0].isdigit(): words = line.split() # Space-delimited 'words' new_words = [] # Construct the new line for i, word in enumerate(words): new_word = word if word in 'Info': continue if i > 1 and any(char.isdigit() or char == '-' for char in word): new_word = ''.join( [char for char in list(word) if char not in 'Info']) new_words.append(new_word) return ' '.join(new_words) return line def _load_gpcan05_pairs_short(self): if self.event.name == 'gpcan05' and self.name == 'pairs_short': with open('0506/gpcan05/pairs_short.pickle') as f: self.scorecards = pickle.load(f) return True return False
import time import urllib.request from ServerConnector import Connector from Panel import Panel bus = smbus.SMBus(1) ADDR = 0x04 WHITE_PIXEL = [0x1, 0x1, 0x1] BLACK_PIXEL = [0x0, 0x0, 0x0] panel1 = Panel(bus, 0x04) panel2 = Panel(bus, 0x05) panels = [[panel2,panel1]] #panel.fill_rect([0,0], [32,32], WHITE_PIXEL) connector = Connector("http://pathealy.pythonanywhere.com/get_grid") while True: try: data = connector.get_dump() for x in range(len(panels)): for y in range(len(panels[x])):
import libtcodpy import random from Console import Console from Panel import Panel test = Console(20, 20, 'test') test.set_fps(10) ptest = Panel(0, 0, 20, 20) ptest.set_default_foreground(libtcodpy.light_gray) pshade = Panel(-1, -1, 10, 10) random.seed(222) fade = 0.1 while not test.is_window_closed: for x in range(0, 20): for y in range(0, 20): if random.randint(0, 2): ptest.write(x, y, '.') if not random.randint(0, 5): ptest.set_default_background(libtcodpy.red) elif not random.randint(0, 5): ptest.set_default_background(libtcodpy.blue) elif not random.randint(0, 5): ptest.set_default_background(libtcodpy.yellow) else: ptest.set_default_background(libtcodpy.black) else: ptest.write(x, y, '#') if not random.randint(0, 3): ptest.set_default_foreground(libtcodpy.red)