def __init__(self): # tracks all the dpg mvKey_ constants self.__keymap = {} for const in dir(core): if const.startswith('mvKey_'): c = getattr(core, const) self.__keymap[c] = {'name': const, 'val': 0} core.set_main_window_size(750, 480) with simple.window("main"): with simple.group("press"): ... core.add_same_line() with simple.group("down"): ... core.add_same_line() with simple.group("release"): ... core.set_key_press_callback(self.__press) core.set_key_down_callback(self.__down) core.set_key_release_callback(self.__release) core.set_render_callback(lambda s, d: self.__render())
def __init__(self): core.set_style_frame_padding(3, 3) core.set_style_window_padding(3, 3) core.set_main_window_size(650, 450) core.set_global_font_scale(1.5) with simple.window("main", autosize=True): with simple.group("panel", width=210): count = max(22, len(_fontnames)) core.add_input_text("regex", label='', default_value=" ") core.add_listbox("font", label='', items=_fontnames, num_items=count, width=210, callback=self.__changed) core.add_same_line() with simple.group("text"): core.add_text( "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\ Phasellus in mollis mauris. Donec tempor felis eget libero accumsan sagittis.\ Integer efficitur urna sed nibh auctor, non hendrerit libero pulvinar.\ Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere\ cubilia curae; In hac habitasse platea dictumst. Vestibulum consectetur,\ sem vitae tristique rhoncus, sem ex maximus ligula, vitae egestas lorem libero\ nec libero. Pellentesque habitant morbi tristique senectus et netus et malesuada\ fames ac turpis egestas. Praesent gravida laoreet pharetra. Ut nec vulputate purus.\ Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos\ himenaeos. Maecenas malesuada neque vel ipsum imperdiet, et lobortis justo sollicitudin.", wrap=560) simple.show_style_editor()
def render(self): with simple.group( self.group, parent=f"cattasks{self.category_id}" ): dpg.add_indent() dpg.add_checkbox( self.id, label=self.label, default_value=self.complete, callback=self.checkbox_check, ) dpg.add_same_line(spacing=10) dpg.add_button( f"up{self.id}", arrow=True, direction=2, callback=self.move_task_up, callback_data={"item": self.group} ) dpg.add_same_line() dpg.add_button( f"down{self.id}", arrow=True, direction=3, callback=self.move_task_down, callback_data={"item": self.group} ) dpg.unindent()
def create_timer(self, **kwargs): """ Creates timer window for composing into other classes :param kwargs: Key words for s.window :return: Create timer window plus timergroup """ window_args = dict( autosize=True, height=150, width=540, x_pos=0, y_pos=0, no_title_bar=True, no_resize=True, no_move=True, no_background=True, no_scrollbar=True, ) for kwarg, value in kwargs.items(): window_args[kwarg] = value with s.window("timer##display", **window_args): with s.group(name="timergroup", horizontal=True): for section in self.display: for cell in section: cell.build_number_box()
def run(self): """ A very basic stand-aloen run method to show what this looks like by default :return: General number display example """ base = BaseGUI(development=True) base.initialize_base_screens() window_args = dict( autosize=False, height=250, width=900, x_pos=0, y_pos=0, no_title_bar=True, no_resize=True, no_move=True, no_background=False, ) with s.window("single_cell", **window_args): with s.group(name="timergroup", horizontal=True): self.build_number_box() self.render(Digit.num_8, 8) c.start_dearpygui()
def make_gui(self): dpg.set_main_window_size(self.width, self.height) dpg.set_theme(self.theme) with simple.window("Main", no_title_bar=True): dpg.set_main_window_title("pytasker") with simple.menu_bar("Menu"): with simple.menu("File"): dpg.add_menu_item("New Page", callback=self.new_tab) dpg.add_menu_item("Load Page", callback=self.load_page) dpg.add_menu_item("Save Page", callback=self.save_page_dialog) dpg.add_separator() dpg.add_menu_item("Quit", callback=self.exit_program) with simple.menu("Themes"): dpg.add_menu_item("Dark", callback=self.theme_callback) dpg.add_menu_item("Light", callback=self.theme_callback) dpg.add_menu_item("Classic", callback=self.theme_callback) dpg.add_menu_item("Dark 2", callback=self.theme_callback) dpg.add_menu_item("Grey", callback=self.theme_callback) dpg.add_menu_item("Dark Grey", callback=self.theme_callback) dpg.add_menu_item("Cherry", callback=self.theme_callback) dpg.add_menu_item("Purple", callback=self.theme_callback) dpg.add_menu_item("Gold", callback=self.theme_callback) dpg.add_menu_item("Red", callback=self.theme_callback) dpg.add_tab_bar(name="tab_bar_1", parent="Main") with simple.group("inittext"): dpg.add_text("Hello! Select File - New to get started")
def construct(self): with simple.group(self.name, parent=self.parent): # GUI elements for the initial coordinate ######################### core.add_text("Initial coordinate (latitude, longitude)") core.add_group("init_input", horizontal=True, horizontal_spacing=0) core.add_input_float2("init_coordinate", label="", format="%f°", width=390) core.add_button( "Sample##input", callback=self.sample_by_mouse, callback_data=("init_coordinate"), ) core.end() # init_input core.add_spacing(count=5) # GUI elements for the destination coordinate ##################### core.add_text("Destination coordinate (latitude, longitude)") core.add_group("destination_input", horizontal=True, horizontal_spacing=0) core.add_input_float2("destination_coordinate", format="%f°", label="", width=390) core.add_button( "Sample##destination", callback=self.sample_by_mouse, callback_data=("destination_coordinate"), ) core.end() # destination_input core.add_spacing(count=5)
def __init__(self): core.set_vsync(False) core.set_style_item_spacing(1, 1) self.__timeline = Timeline() self.__timeline.callback(self.__timelineRender) self.__fps = 0 cmds = { '<<': lambda: self.__timeline.seek(0), '<-': lambda: self.__timeline.play(-1), '||': self.__timeline.stop, '->': lambda: self.__timeline.play(1), '>>': lambda: self.__timeline.seek(-1), '@@': self.__timeline.loop } _width = 60 _size = len(cmds.keys()) * _width with simple.window("main"): with simple.group("MediaBar"): with simple.group("Shuttle"): for k, v in cmds.items(): core.add_button(f"Shuttle#{k}", label=k, width=_width, height=25, callback=v) core.add_same_line() core.add_text("ShuttleFPS") core.add_drag_float("MediabarIndex", label="", width=_size, callback=self.__cbSeek) core.add_color_button("TEST BUTTON", [255, 255, 255], width=400, height=400) self.__timeline.keyEdit("TEST BUTTON", 'width', 0, 400) self.__timeline.keyEdit("TEST BUTTON", 'width', 2., 10) self.__timeline.keyEdit("TEST BUTTON", 'width', 3.75, 400) core.set_render_callback(self.__render)
def init_ui(self): """Initialize the container's UI""" # the monitor profile is in a tab with dpg_simple.tab(self._tab_id, parent=self.parent, no_tooltip=True): # Create 2 groups and put them on the same line with dpg_simple.group(self._left_panel_id, parent=self._tab_id): # The grid input dpg_core.add_input_int2( self._input_id, parent=self._left_panel_id, callback=self.input_callback, default_value=[1, 1], ) # snap button dpg_core.add_button(self._snap_id, parent=self._left_panel_id, callback=self.snap) # Customize grid with the plot dpg_core.add_plot( self._plot_id, parent=self._left_panel_id, height=-1, xaxis_lock_min=True, xaxis_lock_max=True, y2axis_lock_min=True, y2axis_lock_max=True, yaxis_no_tick_marks=True, yaxis_no_tick_labels=True, xaxis_no_tick_marks=True, xaxis_no_tick_labels=True, xaxis_no_gridlines=True, yaxis_no_gridlines=True, ) # Ensure the plot's limits are the work area dpg_core.set_plot_xlimits(self._plot_id, xmin=self.monitor.work.left, xmax=self.monitor.work.right) dpg_core.set_plot_ylimits(self._plot_id, ymin=self.monitor.work.top, ymax=self.monitor.work.bottom) # Put the application table on the right dpg_core.add_same_line(parent=self._tab_id) with dpg_simple.group(self._right_panel_id, parent=self._tab_id): self._app_table = AppTable(parent=self._right_panel_id)
def __init__(self): core.set_style_item_spacing(29, 4) core.set_style_window_padding(0, 0) core.set_main_window_size(1920, 1080) self.__column = 7 self.__row = 58 with simple.window("main"): with simple.group("test", width=187): core.add_button("THE DPG HERO WE NEED...", callback=self.__generate) for c in range(self.__column): core.add_same_line() with simple.group(f"col-{c}", width=187): x = c * self.__row for r in range(self.__row): core.add_text(str(x + r), default_value=" ")
def __init__(self): core.set_main_window_size(720, 540) with simple.window("main"): with simple.group("group"): core.add_button("thread", label='Add Thread', callback=lambda s, d: self.__buttonThread()) self.__bars = {} core.set_render_callback(lambda s, d: self.__render()) core.set_resize_callback(lambda s, d: self.__resize())
def __init__(self): core.set_style_item_spacing(1, 1) core.set_style_window_padding(0, 0) core.enable_docking(shift_only=False, dock_space=True) core.set_main_window_size(690, 450) root = os.path.dirname(__file__) self.__configFile = f'{root}/config.json' with simple.window("main"): with simple.group("test", width=200): core.add_button("button1") core.add_window() with simple.window("floaty", ): with simple.group("test", width=200): core.add_button("button1") core.set_exit_callback(self.__exit) self.__configLoad()
def __init__(self): # row header names to preserve for re-posting table on searching self.__headers = [] # the rows to filter during a search self.__rows = [] cwd = os.path.dirname(__file__) os.chdir(cwd) core.set_main_window_size(800, 750) with simple.window("main"): with simple.group("control"): core.add_button("load", callback=lambda: core.open_file_dialog( callback=self.__load, extensions='.csv')) core.add_input_text("filter", default_value=".*", callback=self.__tableRefresh) with simple.group("panel"): ...
def create_architecture(sender, data): # delete if window already exists core.delete_item('Creating custom arbitrary coupling') with simple.window('Creating custom arbitrary coupling', no_scrollbar=True, height=500, width=600, x_pos=500, y_pos=200): # clear helper value gui.arbitrary_node_list = [] gui.arbitrary_node_connections = {} # get the names of nodes core.add_text('', show=False) with simple.group('node creation##90'): core.add_text( 'Please, list the name of nodes and separate them with commas ",".' ) core.add_text('Please, use unique names:') core.add_input_text("##nodes_list_input", width=380) core.add_button("Enter##a", callback=checkCustomNodes) # get the connections between nodes with simple.group('connection creation##100', show=False): core.add_text('Please, list the connections between nodes.') core.add_text( 'Use numbers to indicate the node and separate them with commas ",":' ) # get the name for this copuling and save it with simple.group('finalization##110', show=False): core.add_text('Please, name this custom copuling.') core.add_text('Maximum 30 symbols:') core.add_input_text("##architecture_name", width=380) core.add_button("Enter##c", callback=checkCustomArhiFile)
def __redraw(self): items = core.get_all_items() if "Layout" in items: core.delete_item("Layout") with simple.group("Layout", parent="MainWindow"): for index, i in enumerate(self.__board): core.add_image_button(f"button-{i}", f"image-{i}", width=self.__width, height=self.__height, frame_padding=0, callback=self.__cbButtonMove) if (index + 1) % self.__rows != 0: core.add_same_line()
def __render(self): for x in ["press", "down", "release"]: kid = f"{x}-kid" if core.does_item_exist(kid): core.delete_item(kid) with simple.group(kid, parent=x, width=250): core.add_text(f'{x}-text', default_value=' ') for k, v in self.__keymap.items(): if v['val'] == 1: core.add_text(v['name'], parent="press-kid") if v['val'] == 2: core.add_text(v['name'], parent="down-kid") if v['val'] == 4: core.add_text(v['name'], parent="release-kid") self.__keymap[k]['val'] = 0
def __init__(self): # turn off the sync to measure FPS core.set_vsync(False) self.__vsync = False with simple.window("main"): with simple.group("group", width=150): core.add_label_text("FPS") core.add_button("vsync", label="Toggle V-Sync On", callback=self.__toggleVsync) core.set_item_color("vsync", core.mvGuiCol_Button, (200, 96, 96, 255)) core.set_render_callback(self.__render) # maximum average the last XX ticks... self.__avgCountMax = 240 self.__avg = []
def add_category(self, sender, data): random_id = util.generate_random_string() with simple.group(f"newcategory{random_id}", parent=f"categories{self.id}"): dpg.add_input_text(f"catlabel{random_id}", label="") dpg.add_same_line(spacing=10) dpg.add_button(f"catdone{random_id}", callback=self.submit_category, label="Done") dpg.add_color_picker4( f"catcolor{random_id}", default_value=[255, 0, 0, 255], height=200, width=200, label="", )
def __init__(self): core.set_main_window_size(720, 540) self.__width = 17 self.__height = 7 self.__total = self.__width * self.__height self.__board = {} size = core.get_main_window_size() self.__paddle = [size[0] * .475, size[1] * .85] self.__paddleSize = (80, 8) # x, y, angle (rads), speed self.__radius = 6 self.__speed = 300 self.__paddleSpeed = 1000 self.__speedMax = self.__speed * 3 self.__pos = (size[0] * .5, size[1] * .8, 0, -self.__speed) with simple.window("main"): with simple.group("scoreboard"): core.add_label_text("score") core.add_same_line() core.add_text("score-value") # core.add_same_line() core.add_label_text("time") core.add_same_line() core.add_text("time-value") core.add_drawing("canvas", width=size[0], height=size[1]) core.draw_circle("canvas", size, self.__radius, (255, 255, 255, 255), fill=(128, 128, 128, 255), tag="ball") core.draw_rectangle("canvas", [ self.__paddle[0] - self.__paddleSize[0], self.__paddle[1] - self.__paddleSize[1] ], [ self.__paddle[0] + self.__paddleSize[0], self.__paddle[1] + self.__paddleSize[1] ], (255, 255, 255, 255), fill=(128, 128, 128, 255), tag="paddle") core.set_resize_callback(self.__resize) core.set_render_callback(self.__render) core.set_key_down_callback(self.__keydown) core.set_mouse_wheel_callback(self.__mousewheel)
def render(self): """ Draw the Category to the screen """ parent_id = self.parent.replace("categories", "") with simple.group( self.group, parent=self.parent, before=f"catspace{parent_id}" ): # Render the Category group dpg.add_spacing(count=2) dpg.add_checkbox( self.id, label="", default_value=self.complete, callback=self.checkbox_check, ) dpg.add_same_line(spacing=10) dpg.add_text(self.label, color=self.color)
def construct(self): self.adjust_coordinate_to_center_tile() with simple.group(self.name, parent=self.parent): core.add_drawing("canvas", width=self.map_size[0], height=self.map_size[1]) core.add_texture( "geomap", self.stored_map, 256 * self.tile_radius, 256 * self.tile_radius, ) if self.cached == False: # Only use if necessary so that the OSM tile servers are not overloaded. self.async_update_by_coordinate(self.latitude, self.longitude, self.zoom) else: self.refresh()
def __init__(self, parent, guid=None, callback=None, **kw): guid = guid or self.__class__.__name__ self.__guid = f'{parent}-{guid}.{ProgressBar._index}' self.__idGroup = f"{self.__guid}-group" ProgressBar._index += 1 self.__callback = callback self.__worker = None self.__q = Queue() self.__value = 0 width, _ = core.get_item_rect_size(parent) width = int(width) kw['width'] = kw.get('width', width) kw['show'] = kw.get('show', False) kw.pop('parent', None) with simple.group(self.__idGroup, width=width, parent=parent): core.add_progress_bar(self.__guid, **kw)
def edit_db(): simple.hide_item("Create Document from Template") session = Session() vars = session.query(Variable).order_by(Variable.name.asc()) with simple.window("Edit Variable DB", **default_window()): core.add_text("All variables") for var in vars: with simple.group(f"{var.name}_group"): core.add_input_text( f"{var.name}_name_db", label="", width=150, enabled=False, default_value=var.name, ) core.add_same_line(spacing=10) core.add_input_text( f"{var.name}_content_db", label="", width=300, default_value=get_content(var.content), ) core.add_same_line(spacing=10) core.add_button( f"{var.name}_update_button_db", label="Update", callback=save_or_update_db, callback_data=(f"{var.name}_name_db", f"{var.name}_content_db"), ) core.add_same_line(spacing=10) core.add_button( f"{var.name}_delete_button_db", label="Delete", callback=remove_variable_gui, callback_data=argparse.Namespace(name=var.name), ) core.add_button( "close_button_db", label="Close Window", callback=close_popup, )
def __init__(self): core.set_style_item_spacing(0, 0) core.set_style_window_padding(0, 0) self.__rows = 0 self.__cap = 0 self.__board = [] self.__width = 0 self.__height = 0 self.__puzzles = {} root = path.dirname(path.realpath(__file__)) for f in listdir(root): full = f"{root}/{f}" if not path.isfile(full) or not f.endswith('.png'): continue who, _ = path.splitext(f) self.__puzzles[who] = full keys = list(self.__puzzles.keys()) self.__puzzle = self.__puzzles[keys[0]] with simple.window("MainWindow", autosize=True): with simple.group("Controls"): for d in [3, 5, 7]: core.add_same_line() core.add_button(f"{d} x {d}", width=120, height=50, callback=self.__clearBoard) core.add_same_line() core.add_dummy() core.add_same_line() core.add_button("Solve!", width=120, height=50, callback=self.__solve) core.add_same_line() items = [p for p in self.__puzzles.keys()] core.add_listbox("selection", items=items, callback=self.__imgChange) self.__clearBoard(self, 3)
def submit_category(self, sender, data): if data: category_label = data["label"] category_color = data["color"] else: parent = dpg.get_item_parent(sender) input_id = parent.replace("newcategory", "") category_label = dpg.get_value(f"catlabel{input_id}") category_color = dpg.get_value(f"catcolor{input_id}") dpg.delete_item(parent) category = trackers.Category(parent=f"categories{self.id}") self.category_tracker.add_category(category) category.label = category_label category.color = category_color if data: category.complete = data["complete"] category.render() if not self.changes: item = dpg.get_item_configuration(self.parent) dpg.configure_item(self.parent, label="!" + item["label"]) self.changes = True # Render the Add Task button with simple.group(f"catitems{category.id}", parent=f"catgroup{category.id}"): dpg.add_group(f"cattasks{category.id}", parent=f"catitems{category.id}") dpg.end() dpg.add_indent() dpg.add_spacing(name=f"taskspace{category.id}") dpg.add_button( f"addtask{category.id}", label="Add New Task", callback=self.add_task, callback_data={"category": category.id}, ) dpg.unindent() return category.id
def add_task(self, sender, data): random_id = util.generate_random_string() parent = dpg.get_item_parent(sender) with simple.group( f"newtask{random_id}", parent=parent.replace("newtask", ""), before=f"taskspace{data.get('category')}", ): dpg.add_indent() dpg.add_input_text(f"tasklabel{random_id}", label="") dpg.add_same_line(spacing=10) dpg.add_button( f"taskdone{random_id}", label="Done", callback=self.submit_task, callback_data={ "parent": parent, "category": data["category"] }, ) dpg.unindent()
def render(self, page_data=None): # Initiate page with simple.group(f"categories{self.id}", parent=self.parent): dpg.add_spacing(name=f"catspace{self.id}", count=1) dpg.add_button( f"addcat{self.id}", callback=self.add_category, label="Add New Category", ) dpg.add_spacing(name="", count=10) if page_data: self.page_name = page_data.get("pagename") self.path = page_data.get("path") self.filename = page_data.get("filename") for category in page_data.get("categories"): category_id = self.submit_category( "", { "label": category["label"], "color": category["color"], "complete": category["complete"], }, ) for task in category["tasks"]: self.submit_task( category_id, { "label": task["label"], "complete": task["complete"], "parent": f"cattasks{category_id}", "category": category_id }, ) item = dpg.get_item_configuration(self.parent) dpg.configure_item(self.parent, label=item["label"].replace("!", "")) self.changes = False
def __init__(self): core.set_style_item_spacing(1, 1) core.set_style_window_padding(0, 0) with simple.window("main"): with simple.group("controls", width=520): with simple.group("buttons"): for x in range(6): core.add_button(f"id-{x}", label=f"button {x}") core.add_color_button("bcolor", (196, 128, 155, 255)) core.add_radio_button("radio") core.add_checkbox("checkbox") core.add_same_line() with simple.group("misc"): core.add_date_picker("date") with simple.group("text"): core.add_text("text") core.add_input_text( "input_text", label="", default_value= "Call me Ish-meal. Tasty like an ashen log.") core.add_label_text("label", label="", default_value="label") core.add_same_line() with simple.group("dropdown"): core.add_listbox("listbox", label="", items=(1, 2, 3)) core.add_combo("combo", label="", items=(1, 2, 3)) for x in ["float", "int"]: with simple.group(x): for what in ["add_drag_", "add_input_"]: for y in ['', 2, 3, 4]: n = f"{what}{x}{y}" cmd = getattr(core, n) cmd(n, label="", width=200) core.add_same_line() manager.ThemeManager()
def start(): """ Renders main window elements. """ with open('token.txt', 'r') as token_file: token = token_file.readline() try: # Connect to IBM core.run_async_function(get_backends_async, data=token) core.set_render_callback(show_button) # Progress bar with simple.window('Please wait', no_scrollbar=True, height=70, width=400, x_pos=500, y_pos=200): core.add_progress_bar('progress', value=0.0, overlay='Connecting to IBM...', width=400) core.run_async_function(progress_async, 0) # Menu bar with simple.menu_bar("Main Menu Bar"): with simple.menu("File"): core.add_menu_item("Save", callback=print_me) core.add_menu_item("Save As", callback=print_me) core.add_menu_item("Help", callback=open_help_window) core.add_menu_item("About", callback=open_about_window) # Parameters group with simple.group('left group', width=350): # Select file button core.add_child('##file_block', width=350, height=180, show=False) core.add_button('File Selector', callback=file_picker) core.add_spacing(name='##space2', count=3) core.add_text('File location:') core.add_label_text('##filedir', value='None Selected', source='directory') core.add_spacing(name='##space3', count=3) core.add_text('File name:') core.add_label_text('##file', value='None Selected', source='file_directory') core.end() core.add_spacing(name='##space4', count=3) # Architecture type radio button core.add_child('##settings_block', width=350, height=450, show=False) core.add_text('Architecture type:') core.add_radio_button('radio##1', items=[ 'IBM simulator', 'IBM quantum computer', 'Arbitrary computer coupling' ], callback=show_architecture_list, source='device_type') core.add_spacing(name='##space5', count=3) # "Create arbitrary coupling" button core.add_button('Create custom architecture', callback=create_architecture, show=False) core.add_spacing(name='##space11', count=3) # Layout radio button core.add_text('Quantum circuit layout method:') core.add_radio_button( 'radio##2', items=['Original IBM layout', 'Advanced SWAP placement'], source='layout_type') core.add_spacing(name='##space6', count=3) # Optimization level slider core.add_text('Optimization level:') core.add_slider_int( '##optimization_lvl', default_value=1, min_value=0, max_value=3, tip='drag the slider to select an optimization level', width=300, source='opt_level') core.add_spacing(name='##space7', count=3) # Number of iterations slider core.add_text('Number of iterations:') core.add_input_int('##num_of_iter', width=300, callback=check_iteration_num, default_value=100) core.add_spacing(name='##space8', count=3) # Default settings button core.add_button('Set Default', callback=set_default) core.end() core.add_spacing(name='##space9', count=3) # Process button core.add_button('Process', callback=process, show=False) # graph images core.add_same_line(name='line##3', xoffset=370) with simple.group('center group'): core.add_child('##images_block', width=640, show=False) # Input circuit preview core.add_text('Input circuit:') core.add_drawing('input_circuit', width=600, height=500) core.draw_rectangle('input_circuit', [0, 150], [600, 500], [255, 255, 255, 0], [255, 255, 255, 50]) # Output circuit view core.add_text('Output circuit:') core.add_drawing('output_circuit', width=600, height=500) core.draw_rectangle('output_circuit', [0, 150], [600, 500], [255, 255, 255, 0], [255, 255, 255, 50]) core.end() # program output core.add_same_line(name='line##3', xoffset=1020) with simple.group('right group'): core.add_child('##output_block1', width=460, height=300, show=False) core.add_button('Open qasm file', callback=open_qasm) core.add_text('Path to IBM circuit representation') core.add_label_text('##circuitImage') core.add_button('Mapping', callback=show_mapping) core.end() core.add_text('Program output:', show=False) core.add_child('##output_block2', width=460, height=180, show=False) core.add_text('Program output will be displayed here', wrap=440) core.end() except Exception as exc: print("[ERROR]: {}".format(exc))
def __init__(self): self.__last = -1 self.__targetFPS = 30 # playhead position self.__head = 0. # playback stopped self.__direction = 0. # looping on self.__loop = True # thread that is "streaming" the video self.__thread = None self.__frameCount = self.__width = self.__height = 0 self.__root = path.dirname(path.realpath(__file__)) core.set_style_item_spacing(1, 1) core.set_style_frame_padding(0, 0) core.get_style_window_padding(0, 0) width = 740 height = 680 core.set_main_window_size(width, height) with simple.window("MainWindow"): core.add_drawing("Canvas", width=width, height=height) w = 50 h = 20 with simple.window("Media Bar", autosize=True, no_collapse=True, no_close=True, no_scrollbar=True): with simple.group("Browser"): core.add_listbox("Listing", label='', items=[], callback=self.__itemChange) with simple.group("Shuttle"): core.add_button("Shuttle#Browse", width=w, height=h, label="...", callback=lambda: core.select_directory_dialog( callback=self.__browser)) core.add_button("Shuttle#Front", width=w, height=h, label='|<', callback=lambda: self.__seek(0)) core.add_same_line() core.add_button("Shuttle#Backwards", width=w, height=h, label='<-', callback=lambda: self.__play(-1)) core.add_same_line() core.add_button("Shuttle#Forwards", width=w, height=h, label='->', callback=lambda: self.__play(1)) core.add_same_line() core.add_button("Shuttle#End", width=w, height=h, label='>|', callback=lambda: self.__seek(-1)) core.add_same_line() core.add_color_button("Shuttle#Loop", [50, 50, 227, 255], width=w, height=h, callback=self.__loopToggle) core.add_same_line() core.add_text("ShuttleFPS") core.add_drag_float("MediabarHead", label="", width=w * 5 + 5, callback=self.__cbSeek) core.set_render_callback(self.__render) core.set_mouse_wheel_callback(self.__mouseWheel) core.set_exit_callback(self.__close) self.__scanDir()