Пример #1
0
def reset_scale():
    """
    Saving the COL_List into the Database
    if there is already a entry into the database the entry will be updated
    """
    core.set_value("Global Scale", 1.0)
    core.set_global_font_scale(1.0)
Пример #2
0
def find_comports(sender, callback):
    #print(list_available_ports())
    comport_list = list_available_ports()
    core.set_value("Click button for new search", comport_list)
    # this takes the first found comport and puts it into the comport to connect
    # on Raspberry, this *should* enable a quick connection
    core.set_value("comport##inputtext", comport_list[0])
Пример #3
0
 def __cbIterationValue(self, sender, data):
     iteration = core.get_value(sender)
     if iteration == self.__iteration:
         return
     core.set_value(sender, iteration)
     self.__iteration = iteration
     self.__refresh()
    def _handle_image_file(self, file_path):

        try:
            self._number_of_scanned_images += 1

            core.set_value(NUMBER_OF_SCANNED_IMAGES,
                           self._number_of_scanned_images)

            stat_return_value = stat(file_path)

            file_size = stat_return_value.st_size
            last_edit_time = stat_return_value.st_mtime

            file_content = self._read_binary_file(file_path, 1024)

            hash_value = self._calc_hash(file_content)

            if hash_value in self.files_dict:
                self.files_dict[hash_value].append(
                    FileMetaData(file_path, file_size, last_edit_time))
            else:
                self.files_dict[hash_value] = [
                    FileMetaData(file_path, file_size, last_edit_time)
                ]

        except Exception as e:
            print('Failed to handle file [%s] with exception: [%s]' %
                  (file_path, e))
Пример #5
0
    def change_mp_percentage(self, sender, data):
        percentage = get_value('% MP')
        self.send_to_pipes(f'MP\\VAL\\{percentage / 100}')

        if get_value('Currently doing nothing on MP. Pick button.') != 'Currently doing nothing on MP. Pick button.':
            set_value('Currently doing nothing on MP. Pick button.',
                      f'Taking MP on {get_value("% MP")}% by clicking on {self.current_mp_btn.split("#")[0]}.')
Пример #6
0
    def import_file(self, sender, data):
        self.dataX1, self.dataX2, self.dataY1, self.dataY2 = [], [], [], []
        self.dataParsedIn = [[]]
        self.dataParsedOut = []
        core.set_value(self.fileStatus, self.fileFound + str(data[1]))
        self.importedFile = open(data[0] + '//' + data[1])
        self.importedFile = self.importedFile.readlines()
        for element in self.importedFile[0][:-1]:
            self.dataParsedIn.append([])

        for line in range(len(self.importedFile)):
            self.dataParsedIn.append([])
            self.importedFile[line] = self.importedFile[line].split()
            for element in range(len(self.importedFile[line][:-1])):
                self.dataParsedIn[element].append(
                    float(self.importedFile[line][element]))
            self.dataParsedOut.append(float(self.importedFile[line][-1]))

            if float(self.importedFile[line][-1]) >= 0.5:
                self.dataX1.append(float(self.importedFile[line][0]))
                self.dataY1.append(float(self.importedFile[line][1]))
            else:
                self.dataX2.append(float(self.importedFile[line][0]))
                self.dataY2.append(float(self.importedFile[line][1]))

        self.display_graph()
Пример #7
0
def _update_dynamic_textures(sender, data):

    global demo_dynamic_texture_1, demo_dynamic_texture_2

    new_color = dpg.get_value(sender)
    new_color[0] = new_color[0] / 255
    new_color[1] = new_color[1] / 255
    new_color[2] = new_color[2] / 255
    new_color[3] = new_color[3] / 255

    if data == 1:
        texture_data = []
        for i in range(0, 100 * 100):
            texture_data.append(new_color[0])
            texture_data.append(new_color[1])
            texture_data.append(new_color[2])
            texture_data.append(new_color[3])
        dpg.set_value(demo_dynamic_texture_1, texture_data)

    elif data == 2:
        texture_data = []
        for i in range(0, 50 * 50):
            texture_data.append(new_color[0])
            texture_data.append(new_color[1])
            texture_data.append(new_color[2])
            texture_data.append(new_color[3])
        dpg.set_value(demo_dynamic_texture_2, texture_data)
Пример #8
0
 def update_listbox(self):
     core.configure_item("algorithm_selector##available",
                         items=self.available_algorithms)
     core.set_value("algorithm_selector##available", 0)
     core.configure_item("algorithm_selector##selected",
                         items=self.selected_algorithms)
     core.set_value("algorithm_selector##selected", 0)
Пример #9
0
    def input_callback(self, sender, data):
        """Callback when the input grids are changed"""
        dpg_core.log_info(
            f"Refreshing grid for monitor profile {self.monitor.name} as input changed"
        )
        # First remove each line from the plot
        for xline in self._xlines:
            dpg_core.delete_drag_line(self._plot_id, xline)
        for yline in self._ylines:
            dpg_core.delete_drag_line(self._plot_id, yline)

        # Ensure that the values are greater than or equal to 1
        rows, cols = dpg_core.get_value(self._input_id)
        rows = 1 if rows < 1 else rows
        cols = 1 if cols < 1 else cols
        dpg_core.set_value(self._input_id, [rows, cols])

        # Add horizontal lines to the plot
        ylines = []
        for row in range(1, rows):
            name = f"yline{row}-{self.id}"
            pos = int(self.monitor.work.top +
                      (row / rows) * self.monitor.work.height)
            dpg_core.add_drag_line(
                self._plot_id,
                name,
                y_line=True,
                show_label=False,
                default_value=pos,
                callback=self.line_callback,
            )
            ylines.append(name)

        # Add vertical lines to the plot
        xlines = []
        for col in range(1, cols):
            name = f"xline{col}-{self.id}"
            pos = int(self.monitor.work.left +
                      (col / cols) * self.monitor.work.width)
            dpg_core.add_drag_line(
                self._plot_id,
                name,
                y_line=False,
                show_label=False,
                default_value=pos,
                callback=self.line_callback,
            )
            xlines.append(name)

        self._xlines = xlines
        self._ylines = ylines

        # Reset the labels and application table to reflect the new grids
        self.set_labels()
        self._app_table.clear()
        self._app_table.set_rows(rows * cols)
        dpg_core.log_info(
            f"Refreshed grid for monitor profile {self.monitor.name} as input changed"
        )
Пример #10
0
def apply_selected_directory(sender, data):
    """
    Sets the file name
    """
    directory = data[0]
    file_directory = data[1]
    core.set_value('directory', directory)
    core.set_value('file_directory', file_directory)
Пример #11
0
def add_variable_gui(sender, data):
    args = argparse.Namespace(name=core.get_value(data[0]),
                              content=core.get_value(data[1]),
                              tag=None)

    for input in data:
        core.set_value(input, "")
    add_variable(args)
Пример #12
0
def progress_async(sender, data):
    """
    Fills progress bar.
    """
    counter = 0.0
    while (not gui.server_on):
        core.set_value('progress', value=counter)
        counter += 0.001
        time.sleep(0.001)
Пример #13
0
 def switch_task(self, *_args) -> None:
     """
     Saves entry but maintains timer so updating description is inline
     :param _args: sender, data in 0, 1 tuple position
     :return: None
     """
     self.save_new_entry()
     self.set_start_time()
     c.set_value("Description", "")
Пример #14
0
 def __set_output_directory(self, sender, data):
     directory = data[0]
     selected_folder = data[1]
     if selected_folder in directory:
         self.output_directory = directory
     else:
         self.output_directory = '\\'.join(data)
     print(self.output_directory)
     dpg.set_value('Selected output directory:', f'Selected output directory: {self.output_directory}')
Пример #15
0
	def run(self):
		while self.is_alive:
			val, overlay = self.__q.get()
			if val is None:
				break
			core.configure_item(self.__progressBar.guid, overlay=overlay)
			core.set_value(self.__progressBar.guid, val)

		if self.__callback:
			self.__callback()
Пример #16
0
def create(sender, data):
    core.set_value("company_id",
                   "{} Model Created".format(model_company.split('_')[0]))
    core.clear_plot("Pred")
    predict, original = data
    core.add_line_series("Pred",
                         "Prediction",
                         predict.index.tolist(),
                         predict[0].tolist(),
                         color=[255, 50, 50, 100])
Пример #17
0
 def update_on_click(sender):
     pos_x, pos_y = core.get_drawing_mouse_pos()
     sx, sy = self.context.get_drawing_size()
     coordinates = self.context.pixel_to_coordinate(
         pos_x / sx, (sy - pos_y) / sy)
     logging.info(
         f"Selected coordinate: lat: {coordinates[0]}°, long: {coordinates[1]}°"
     )
     core.set_value(callback_object, coordinates)
     core.set_mouse_click_callback(None)
Пример #18
0
 def _translate_text_callback(self, sender, data: Payload):
     """
     The callback portion of the translate_text method.
     Here the translated text is taken from data and put into the value storage with key data.destination_value_name.
     :param sender:
     :param data: Payload object
     :return:
     """
     core.set_value(data.destination_value_name, data.text)
     self._enable_widgets(data.enable)
Пример #19
0
    def __add_file(self, sender, data):
        is_file_unique = True

        for f in self.files_list:
            if f['name'] == data[1]:
                is_file_unique = False

        if is_file_unique:
            self.files_list.append({'path': data[0], 'name': data[1]})
        else:
            dpg.set_value('##warnings', "There are files with the same name.")
Пример #20
0
 def __toggle_stock(self, sender, data):
     """Toggle a todo to True of False.
     Get the selected cell of the table (list of [row index, column index])
     and uses the row index to update the todo at that index in the todos
     list. Then, saves the selected row index in the case you would want to
     delete that todo.
     """
     stock_row = dpg.get_table_selections("Stocks")
     stock = self.stocks[stock_row[0][0]]
     dpg.add_data("selected-stock-index", self.stocks.index(stock))
     dpg.set_value("Selected stock:", f"Selected Stock: {stock['Stock']}")
Пример #21
0
    def load_dict(self, serialized_monitor_profile: dict[str,
                                                         list[float]]) -> None:
        """Set the monitor profile from a serialized dictionary

        Parameters
        ----------
        serialized_monitor_profile : dict[str, list[float]]
            Dictionary to load
        """
        dpg_core.log_info(f"Loading monitor profile {self.id}")
        for xline in self._xlines:
            dpg_core.delete_drag_line(self._plot_id, xline)
        for yline in self._ylines:
            dpg_core.delete_drag_line(self._plot_id, yline)

        dpg_core.log_debug("Setting loaded ylines")
        ylines = []
        for row, value in enumerate(serialized_monitor_profile["ylines"]):
            dpg_core.log_debug("Loading y lines")
            yline = int(value * self.monitor.work.height)
            name = f"yline{row}-{self.id}"
            dpg_core.add_drag_line(
                self._plot_id,
                name,
                y_line=True,
                show_label=False,
                default_value=yline,
                callback=self.line_callback,
            )
            ylines.append(name)

        dpg_core.log_debug("Setting loaded xlines")
        xlines = []
        for col, value in enumerate(serialized_monitor_profile["xlines"]):
            yline = int(value * self.monitor.work.width)
            name = f"xline{col}-{self.id}"
            dpg_core.add_drag_line(
                self._plot_id,
                name,
                y_line=False,
                show_label=False,
                default_value=yline,
                callback=self.line_callback,
            )
            xlines.append(name)

        self._xlines = xlines
        self._ylines = ylines

        self.set_labels()
        rows, cols = (len(self._ylines) + 1), (len(self._xlines) + 1)
        dpg_core.set_value(self._input_id, [rows, cols])
        self._app_table.set_rows(rows * cols)
        dpg_core.log_info(f"Loaded monitor profile {self.id}")
Пример #22
0
    def __zip_files(self, sender, data):
        dpg.set_value('Zip Progress', 0)
        with ZipFile(f'{self.output_directory}\\{uuid.uuid4().hex}.zip', 'w') as zip_file:
            current_progress = 0
            total_progress = len(self.files_list)
            for f in self.files_list:
                full_path = f['path'] + "\\" + f['name']
                zip_file.write(full_path, f['name'])

                # Update progress bar
                current_progress += 1
                dpg.set_value('Zip Progress', current_progress / total_progress)
Пример #23
0
	def __render(self):
		delta = 1. / core.get_delta_time()
		self.__avg.append(delta)

		# average over X items
		count = len(self.__avg)
		if count > self.__avgCountMax:
			self.__avg.pop(0)

		# trim to a few significance
		avg = int(sum(self.__avg) / count * 1000)
		core.set_value("FPS", avg / 1000.)
Пример #24
0
 def __toggle_todo(self, sender, data):
     """Toggle a todo to True of False.
     Get the selected cell of the table (list of [row index, column index])
     and uses the row index to update the todo at that index in the todos
     list. Then, saves the selected row index in the case you would want to
     delete that todo.
     """
     todo_row = dpg.get_table_selections("Todos")
     todo = self.todos[todo_row[0][0]]
     todo['done'] = not todo['done']
     dpg.add_data('selected-todo-index', self.todos.index(todo))
     dpg.set_value('Selected todo:', f"Selected id: {todo['id']}")
Пример #25
0
 def buy_or_sell(self, sender, data):
     (stock, ) = data
     currently_owned = self.player.get_owned_stocks(stock)
     change = core.get_value(sender) - currently_owned
     if change > 0:
         self.player.buy_stock(stock, change)
     elif change < 0:
         self.player.sell_stock(stock, -change)
     else:
         return  # Empty handed
     core.set_value("cash", self.player.cash)
     self.update_buy_caps()
Пример #26
0
 def __add_todo(self, sender, data):
     """Add a new todo.
     Get the data from the input text, append a new todo to the todos list
     and then clear the text of the input.
     """
     new_todo_content = dpg.get_value('new-todo-title')
     new_todo = {
         'id': uuid.uuid4().hex,
         'content': new_todo_content,
         'done': False
     }
     self.todos.append(new_todo)
     dpg.set_value('new-todo-title', '')
Пример #27
0
def predict_button(sender, data):
    sepLength = core.get_value("Sepal Length")
    sepWidth = core.get_value("Sepal Width")
    petLength = core.get_value("Petal Length")
    petWidth = core.get_value("Petal Width")
    features = [[
        float(sepLength),
        float(sepWidth),
        float(petLength),
        float(petWidth)
    ]]
    result = model.predict(features)
    core.set_value("rs", result.title())
Пример #28
0
def fakeItTillYouMakeIt():
    while 1:
        for idx in range(_COUNT):
            plot = f"plot-{idx}"
            value = core.get_value(plot)
            # any data will do
            r = random.random() * 12 + 60
            value.append(r)
            # Do not over cache
            if len(value) > _MAXHISTORY:
                value.pop(0)
            core.set_value(plot, value)
        sleep(_TICKRATE)
Пример #29
0
def disable_all(sender):
    """
    Checkbox Disable all;
    get all checkbox Items and set them to False
    Call the changes_detected function to set iChanges to 1
    """
    items = core.get_all_items()
    for i in items:
        if "stats" in i and "stats" in sender:
            core.set_value(i, False)
        if "match" in i and "match" in sender:
            core.set_value(i, False)
    changes_detected()
Пример #30
0
    def __render(self):
        delta = core.get_delta_time()
        fps = 1. / delta

        ratio = self.__targetFPS / fps
        core.set_value('ShuttleFPS', int(fps))
        core.set_value('MediabarHead', self.__head)
        if self.__direction == 0:
            return

        # adjust the frame(s) to playback? based on last frametime?
        # for now, just play a single "frame"
        self.__head += (ratio * self.__direction)
        self.__renderFrame()