def __init__(self, parent, mainWindow, **kwargs): tk.Frame.__init__(self, parent, **kwargs) self.mainWindow = mainWindow self.columnconfigure(0, weight=1) self.columnconfigure(4, weight=1) self.configure(pady=10) tk.Frame(self, height="0", width="1").grid(row="0", column="0") tk.Frame(self, height="0", width="1").grid(row="0", column="4") self.counter = 0 checkboxValue = tk.BooleanVar() checkboxValue.set(settings.getGraphDisabled()) self.graphDisabled = tk.Checkbutton(self, text="完全禁用图象", variable=checkboxValue) self.graphDisabled.var = checkboxValue self.graphDisabled.grid(row=self.counter, column="1", columnspan="2") descriptor = tk.Label(self, text="数据标签将仍被显示") font = tkFont.Font(font=descriptor['font']) font.config(slant='italic') descriptor['font'] = font descriptor.grid(row=self.counter + 1, column="1", columnspan="2") tk.Frame(self, height="20", width="10").grid(row=self.counter + 2, column="1", columnspan="5") self.counter += 3 self.secondsVar = tk.StringVar() self.secondsVar.set(settings.getSeconds()) self.addSetting(self.secondsVar, "每求一次数据平均值的时间间隔(秒):", "建议将此值设定为高于你武器射速的数值。") self.intervalVar = tk.StringVar() self.intervalVar.set(settings.getInterval()) self.addSetting(self.intervalVar, "更新图象与数据标签的时间间隔(毫秒):", "该值越低,电脑CPU的占用越高。") self.transparencyVar = tk.StringVar() self.transparencyVar.set(settings.getCompactTransparency()) self.addSetting(self.transparencyVar, "紧凑模式下的窗口透明度:", "100为完全可见,0为完全不可见。")
def __init__(self, parent, mainWindow, **kwargs): tk.Frame.__init__(self, parent, **kwargs) self.mainWindow = mainWindow self.columnconfigure(0, weight=1) self.columnconfigure(4, weight=1) self.configure(pady=10) tk.Frame(self, height="0", width="1").grid(row="0", column="0") tk.Frame(self, height="0", width="1").grid(row="0", column="4") self.counter = 0 checkboxValue = tk.BooleanVar() checkboxValue.set(settings.getGraphDisabled()) self.graphDisabled = tk.Checkbutton(self, text="禁用统计图", variable=checkboxValue) self.graphDisabled.var = checkboxValue self.graphDisabled.grid(row=self.counter, column="1", columnspan="2") descriptor = tk.Label(self, text="标签仍然会显示") font = tkFont.Font(font=descriptor['font']) font.config(slant='italic') descriptor['font'] = font descriptor.grid(row=self.counter+1, column="1", columnspan="2") tk.Frame(self, height="20", width="10").grid(row=self.counter+2, column="1", columnspan="5") self.counter += 3 self.secondsVar = tk.StringVar() self.secondsVar.set(settings.getSeconds()) self.addSetting(self.secondsVar, "DPS计算周期(秒):", "建议将此条设置为比你武器循环时间高一点的整数") self.intervalVar = tk.StringVar() self.intervalVar.set(settings.getInterval()) self.addSetting(self.intervalVar, "图形绘制周期(毫秒):", "数值越低CPU负担越大") self.transparencyVar = tk.StringVar() self.transparencyVar.set(settings.getCompactTransparency()) self.addSetting(self.transparencyVar, "Compat模式的透明度:", "100为不透明,0为全透明")
def __init__(self, parent, mainWindow, **kwargs): tk.Frame.__init__(self, parent, **kwargs) self.mainWindow = mainWindow self.columnconfigure(0, weight=1) self.columnconfigure(4, weight=1) self.configure(pady=10) tk.Frame(self, height="0", width="1").grid(row="0", column="0") tk.Frame(self, height="0", width="1").grid(row="0", column="4") self.counter = 0 checkboxValue = tk.BooleanVar() checkboxValue.set(settings.getGraphDisabled()) self.graphDisabled = tk.Checkbutton(self, text="Disable graph entirely", variable=checkboxValue) self.graphDisabled.var = checkboxValue self.graphDisabled.grid(row=self.counter, column="1", columnspan="2") descriptor = tk.Label(self, text="Labels will still be shown") font = tkFont.Font(font=descriptor['font']) font.config(slant='italic') descriptor['font'] = font descriptor.grid(row=self.counter+1, column="1", columnspan="2") tk.Frame(self, height="20", width="10").grid(row=self.counter+2, column="1", columnspan="5") self.counter += 3 self.secondsVar = tk.StringVar() self.secondsVar.set(settings.getSeconds()) self.addSetting(self.secondsVar, "Number of seconds to average values:", "Recommended to set this value higher than your weapon cycle time") self.intervalVar = tk.StringVar() self.intervalVar.set(settings.getInterval()) self.addSetting(self.intervalVar, "How often to update graph/labels in milliseconds:", "The lower you set this value, the higher your CPU usage will be") self.transparencyVar = tk.StringVar() self.transparencyVar.set(settings.getCompactTransparency()) self.addSetting(self.transparencyVar, "Window transparency percentage in compact mode:", "100 is fully visible, 0 is invisible")
def __init__(self): tk.Tk.__init__(self) self.baseWindow = BaseWindow(self) self.minsize(175, 50) # Set title and icon for alt+tab and taskbar self.wm_title("PyEveLiveDPS Main Window") try: self.iconbitmap(sys._MEIPASS + '\\app.ico') except Exception: try: self.iconbitmap("app.ico") except Exception: pass self.addToTaskbar() # label that appears at the top of the window in special modes like simulation and playback modes self.topLabel = tk.Label(self, text="模拟模式", fg="white", background="black") font = tkFont.Font(font=self.topLabel['font']) font.config(slant='italic') self.topLabel['font'] = font self.topLabel.grid(row="5", column="5", columnspan="8") self.topLabel.grid_remove() self.makeDraggable(self.topLabel) # Other items for setting up the window self.addQuitButton() self.addCollapseButton(self, row="5", column="17") tk.Frame(self, height=1, width=5, background="black").grid(row="5", column="16") self.addMinimizeButton(self, row="5", column="15") self.addMenus() # Container for our "dps labels" and graph self.middleFrame = tk.Frame(self, background="black") self.middleFrame.columnconfigure(0, weight=1) self.middleFrame.rowconfigure(1, weight=1) self.middleFrame.grid(row="10", column="1", columnspan="19", sticky="news") self.makeDraggable(self.middleFrame) self.middleFrame.bind("<Map>", self.showEvent) self.protocol("WM_TAKE_FOCUS", lambda: self.showEvent(None)) self.labelHandler = labelHandler.LabelHandler(self.middleFrame, background="black") self.labelHandler.grid(row="0", column="0", sticky="news") self.makeDraggable(self.labelHandler) # set the window size and position from the settings self.geometry("%sx%s+%s+%s" % (settings.getWindowWidth(), settings.getWindowHeight(), settings.getWindowX(), settings.getWindowY())) self.update_idletasks() # The hero of our app self.graphFrame = graph.DPSGraph(self.middleFrame, background="black", borderwidth="0") self.graphFrame.grid(row="1", column="0", columnspan="3", sticky="nesw") self.makeDraggable(self.graphFrame.canvas.get_tk_widget()) # details window is a child of the main window, but the window will be hidden based on the profile settings self.detailsWindow = DetailsWindow(self) self.fleetWindow = FleetWindow(self) # the animator is the main 'loop' of the program self.animator = animate.Animator(self) self.bind('<<ChangeSettings>>', lambda e: self.animator.changeSettings()) self.graphFrame.readjust(0) if settings.getGraphDisabled(): self.graphFrame.grid_remove() else: self.graphFrame.grid() self.labelHandler.lift(self.graphFrame) self.makeAllChildrenDraggable(self.labelHandler) logging.info('main window (and subcomponents) initialized')
def changeSettings(self): """This function is called when a user changes settings after the settings are verified""" if self.is_alive(): self.paused = True self.mainWindow.after_cancel(self.animate) self.graph.subplot.clear() if self.simulationEnabled: self.simulationSettings(enable=False) self.mainWindow.mainMenu.menu.delete(7) self.mainWindow.mainMenu.menu.insert_command( 7, label="Simulate Input", command=lambda: simulationWindow.SimulationWindow(self. mainWindow)) self.mainWindow.topLabel.grid_remove() self.mainWindow.mainMenu.menu.entryconfig(5, state="normal") self.slowDown = False self.seconds = settings.getSeconds() self.interval = settings.getInterval() self.categories["dpsOut"]["settings"] = settings.getDpsOutSettings() self.categories["dpsIn"]["settings"] = settings.getDpsInSettings() self.categories["logiOut"]["settings"] = settings.getLogiOutSettings() self.categories["logiIn"]["settings"] = settings.getLogiInSettings() self.categories["capTransfered"][ "settings"] = settings.getCapTransferedSettings() self.categories["capRecieved"][ "settings"] = settings.getCapRecievedSettings() self.categories["capDamageOut"][ "settings"] = settings.getCapDamageOutSettings() self.categories["capDamageIn"][ "settings"] = settings.getCapDamageInSettings() self.categories["mining"]["settings"] = settings.getMiningSettings() self.graphDisabled = settings.getGraphDisabled() if self.graphDisabled: self.graph.grid_remove() else: self.graph.grid() self.labelHandler.redoLabels() self.mainWindow.makeAllChildrenDraggable(self.labelHandler) if settings.detailsWindowShow: self.mainWindow.detailsWindow.deiconify() else: self.mainWindow.detailsWindow.withdraw() if self.fleetMode and settings.fleetWindowShow: self.mainWindow.fleetWindow.deiconify() else: self.mainWindow.fleetWindow.withdraw() self.arrayLength = int((self.seconds * 1000) / self.interval) historicalTemplate = [0] * self.arrayLength yValuesTemplate = np.array([0] * self.arrayLength) ySmooth = self.graph.smoothListGaussian(yValuesTemplate, 5) # resets all the arrays to contain no values showAnyPeakOrTotal = False for category, items in self.categories.items(): if items["settings"]: self.labelHandler.enableLabel(category, True) showPeak = items["settings"][0].get("showPeak", False) self.labelHandler.enablePeak(category, showPeak) showTotal = items["settings"][0].get("showTotal", False) findColor = lambda x, category=category: self.findColor( category, x) showAnyPeakOrTotal = showAnyPeakOrTotal or showPeak or showTotal self.labelHandler.enableTotal(category, findColor, showTotal) self.detailsHandler.enableLabel(category, True) items["historical"] = historicalTemplate.copy() items["historicalDetails"] = [[]] * self.arrayLength items["yValues"] = yValuesTemplate.copy() items["labelOnly"] = items["settings"][0].get( "labelOnly", False) if not items["labelOnly"]: plotLine, = self.graph.subplot.plot(ySmooth, zorder=items["zorder"]) items["lines"] = [plotLine] else: self.labelHandler.enableLabel(category, False) self.labelHandler.enablePeak(category, False) self.detailsHandler.enableLabel(category, False) self.mainWindow.showClearMenuOption( showAnyPeakOrTotal, lambda: self.labelHandler.clearValues(self.findColor)) if not self.graphDisabled: self.graph.subplot.margins(0, 0) self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100) self.graph.graphFigure.canvas.draw() # reset fleet data characterName = self.mainWindow.fleetWindow.characterName if self.dataQueue: self.fleetData = { 'aggregate': { 'dpsOut': { 'historical': historicalTemplate.copy(), 'yValues': yValuesTemplate.copy() }, 'dpsIn': { 'historical': historicalTemplate.copy(), 'yValues': yValuesTemplate.copy() }, 'logiOut': { 'historical': historicalTemplate.copy(), 'yValues': yValuesTemplate.copy() } }, 'dpsOut': { characterName: { 'historical': historicalTemplate.copy(), 'yValues': yValuesTemplate.copy() } }, 'dpsIn': { characterName: { 'historical': historicalTemplate.copy(), 'yValues': yValuesTemplate.copy() } }, 'logiOut': { characterName: { 'historical': historicalTemplate.copy(), 'yValues': yValuesTemplate.copy() } } } self.mainWindow.fleetWindow.resetGraphs(ySmooth) self.mainWindow.fleetWindow.changeSettings() self.paused = False
def changeSettings(self): """This function is called when a user changes settings after the settings are verified""" if self.is_alive(): self.paused = True self.mainWindow.after_cancel(self.animate) self.graph.subplot.clear() if self.simulationEnabled: self.simulationSettings(enable=False) self.mainWindow.mainMenu.menu.delete(5) self.mainWindow.mainMenu.menu.insert_command(5, label="Simulate Input", command=lambda: simulationWindow.SimulationWindow(self.mainWindow)) self.mainWindow.topLabel.grid_remove() self.mainWindow.mainMenu.menu.entryconfig(3, state="normal") self.slowDown = False self.seconds = settings.getSeconds() self.interval = settings.getInterval() self.categories["dpsOut"]["settings"] = settings.getDpsOutSettings() self.categories["dpsIn"]["settings"] = settings.getDpsInSettings() self.categories["logiOut"]["settings"] = settings.getLogiOutSettings() self.categories["logiIn"]["settings"] = settings.getLogiInSettings() self.categories["capTransfered"]["settings"] = settings.getCapTransferedSettings() self.categories["capRecieved"]["settings"] = settings.getCapRecievedSettings() self.categories["capDamageOut"]["settings"] = settings.getCapDamageOutSettings() self.categories["capDamageIn"]["settings"] = settings.getCapDamageInSettings() self.categories["mining"]["settings"] = settings.getMiningSettings() self.graphDisabled = settings.getGraphDisabled() if self.graphDisabled: self.graph.grid_remove() else: self.graph.grid() self.labelHandler.redoLabels() if settings.detailsWindowShow: self.mainWindow.detailsWindow.deiconify() else: self.mainWindow.detailsWindow.withdraw() # resets all the arrays to contain no values for category, items in self.categories.items(): if items["settings"]: self.labelHandler.enableLabel(category, True) self.detailsHandler.enableLabel(category, True) items["historical"] = [0] * int((self.seconds*1000)/self.interval) items["historicalDetails"] = [[]] * int((self.seconds*1000)/self.interval) items["yValues"] = np.array([0] * int((self.seconds*1000)/self.interval)) try: items["labelOnly"] = items["settings"][0]["labelOnly"] except KeyError: items["settings"][0]["labelOnly"] = False items["labelOnly"] = items["settings"][0]["labelOnly"] if not items["labelOnly"]: ySmooth = self.graph.smoothListGaussian(items["yValues"], 5) plotLine, = self.graph.subplot.plot(ySmooth, zorder=items["zorder"]) items["lines"] = [plotLine] else: self.labelHandler.enableLabel(category, False) self.detailsHandler.enableLabel(category, False) if not self.graphDisabled: self.graph.subplot.margins(0,0) self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100) self.graph.graphFigure.canvas.draw() self.paused = False