Пример #1
0
    def __init__(self, parent, labelHandler, **kwargs):
        tk.Frame.__init__(self, parent, **kwargs)

        self.parent = parent
        self.labelHandler = labelHandler

        self.degree = 5
        self.windowWidth = settings.getWindowWidth()

        self.graphFigure = Figure(figsize=(4, 2), dpi=100, facecolor="black")

        self.subplot = self.graphFigure.add_subplot(1,
                                                    1,
                                                    1,
                                                    facecolor=(0.3, 0.3, 0.3))
        self.subplot.tick_params(axis="y", colors="grey", direction="in")
        self.subplot.tick_params(axis="x",
                                 colors="grey",
                                 labelbottom="off",
                                 bottom="off")

        self.graphFigure.axes[0].get_xaxis().set_ticklabels([])
        self.graphFigure.subplots_adjust(left=(30 / self.windowWidth),
                                         bottom=(15 / self.windowWidth),
                                         right=1,
                                         top=(1 - 15 / self.windowWidth),
                                         wspace=0,
                                         hspace=0)

        self.canvas = FigureCanvasTkAgg(self.graphFigure, self)
        self.canvas.get_tk_widget().configure(bg="black")
        self.canvas.get_tk_widget().pack(side=tk.BOTTOM,
                                         fill=tk.BOTH,
                                         expand=True)

        self.canvas.draw()
Пример #2
0
    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')
Пример #3
0
 def animate(self):
     """ this function gets called every 'interval', and handles all the tracking data """
     try:
         # data points are retrieved from either the simulator or the EVE logs
         if self.simulationEnabled:
             newEntries = self.simulator.simulate()
         else:
             newEntries = self.characterDetector.readLog()
         
         # insert all the new values into the categories entries
         self.categories["dpsOut"]["newEntry"] = newEntries[0]
         self.categories["dpsIn"]["newEntry"] = newEntries[1]
         self.categories["logiOut"]["newEntry"] = newEntries[2]
         self.categories["logiIn"]["newEntry"] = newEntries[3]
         self.categories["capTransfered"]["newEntry"] = newEntries[4]
         self.categories["capRecieved"]["newEntry"] = newEntries[5]
         self.categories["capDamageOut"]["newEntry"] = newEntries[6]
         self.categories["capDamageIn"]["newEntry"] = newEntries[7]
         self.categories["mining"]["newEntry"] = newEntries[8]
         interval = settings.getInterval()
         
         # pops old values, adds new values, and passes those to the graph and other handlers
         for category, items in self.categories.items():
             if self.queue and category != 'mining':
                 for entry in items["newEntry"]:
                     self.queue.put({"category": category, "entry": entry})
             # if items["settings"] is empty, this isn't a category that is being tracked
             if items["settings"]:
                 # remove old values
                 items["historical"].pop(0)
                 items["historicalDetails"].pop(0)
                 # as values are broken up by weapon, add them together for the non-details views
                 amountSum = sum([entry['amount'] for entry in items["newEntry"]])
                 items["historical"].insert(len(items["historical"]), amountSum)
                 items["historicalDetails"].insert(len(items["historicalDetails"]), items["newEntry"])
                 # 'yValues' is for the actual DPS at that point in time, as opposed to raw values
                 items["yValues"] = items["yValues"][1:]
                 average = (np.sum(items["historical"])*(1000/interval))/len(items["historical"])
                 items["yValues"] = np.append(items["yValues"], average)
                 # pass the values to the graph and other handlers
                 if not items["labelOnly"] and not self.graphDisabled:
                     self.graph.animateLine(items["yValues"], items["settings"], items["lines"], zorder=items["zorder"])
                     self.labelHandler.updateLabel(category, average, matplotlib.colors.to_hex(items["lines"][-1].get_color()))
                 else:
                     color = self.findColor(category, average)
                     self.labelHandler.updateLabel(category, average, color)
                 self.detailsHandler.updateDetails(category, items["historicalDetails"])
         
         # Find highest average for the y-axis scaling
         # We need to track graph avg and label avg separately, since graph avg is used for y-axis scaling
         #  and label average is needed for detecting when to slow down the animation
         self.highestAverage = 0
         self.highestLabelAverage = 0
         for category, items in self.categories.items():
             if items["settings"] and not items["labelOnly"]:
                 for value in items["yValues"]:
                     if (value > self.highestAverage):
                         self.highestAverage = value
             elif items["settings"]:
                 for value in items["yValues"]:
                     if (value > self.highestAverage):
                         self.highestLabelAverage = value
         
         if not self.graphDisabled:
             if (self.highestAverage < 100):
                 self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=100)
             else:
                 self.graph.graphFigure.axes[0].set_ylim(bottom=0, top=(self.highestAverage+self.highestAverage*0.1))
             self.graph.graphFigure.axes[0].get_yaxis().grid(True, linestyle="-", color="grey", alpha=0.2)
             self.graph.readjust(settings.getWindowWidth(), self.highestAverage)
         
         # if there are no values coming in to the graph, enable 'slowDown' mode to save CPU
         if (self.highestAverage == 0 and self.highestLabelAverage == 0):
             if not self.slowDown:
                 self.slowDown = True
                 self.interval = 500
         else:
             if self.slowDown:
                 self.slowDown = False
                 self.interval = settings.getInterval()
         
         # display of pilot details is handled after all values are updated, for sorting and such
         self.detailsHandler.cleanupAndDisplay(interval, int((self.seconds*1000)/self.interval), lambda x,y: self.findColor(x,y))
 
         if not self.graphDisabled:
             self.graph.graphFigure.canvas.draw()
         
     except Exception as e:
         logging.exception(e)