示例#1
0
 def __init__(self, mainWindow):
     tk.Toplevel.__init__(self)
     
     self.mainWindow = mainWindow
     self.graph = mainWindow.getGraph()
     self.animator = mainWindow.animator
     
     self.values = {}
     
     self.wm_attributes("-topmost", True)
     self.wm_title("PyEveLiveDPS Simulation Settings")
     try:
         self.iconbitmap(sys._MEIPASS + '\\app.ico')
     except Exception:
         try:
             self.iconbitmap("app.ico")
         except Exception:
             pass
     self.geometry("300x120")
     self.update_idletasks()
     
     self.columnconfigure(0, weight=1)
     
     tk.Label(self, text="For each item, a random number will be chosen\n in the range you specify every cycle.").grid(row="0", column="0", columnspan="10")
     
     tk.Frame(self, height="20", width="1").grid(row="1", column="1", columnspan="5")
     
     self.innerFrame = tk.Frame(self)
     self.innerFrame.grid(row="2", column="0")
     
     if settings.getDpsOutSettings():
         tk.Label(self.innerFrame, text="DPS Out:").grid(row="2", column="0", sticky="e")
         self.addRow("dpsOut", "2")
     if settings.getLogiOutSettings():
         tk.Label(self.innerFrame, text="Logistics Out:").grid(row="3", column="0", sticky="e")
         self.addRow("logiOut", "3")
     if settings.getCapTransferedSettings():
         tk.Label(self.innerFrame, text="Cap Transfer Out:").grid(row="4", column="0", sticky="e")
         self.addRow("capOut", "4")
     if settings.getCapDamageOutSettings():
         tk.Label(self.innerFrame, text="Cap Warfare Out:").grid(row="5", column="0", sticky="e")
         self.addRow("neutOut", "5")
     if settings.getDpsInSettings():
         tk.Label(self.innerFrame, text="DPS In:").grid(row="6", column="0", sticky="e")
         self.addRow("dpsIn", "6")
     if settings.getLogiInSettings():
         tk.Label(self.innerFrame, text="Logistics In:").grid(row="7", column="0", sticky="e")
         self.addRow("logiIn", "7")
     if settings.getCapRecievedSettings():
         tk.Label(self.innerFrame, text="Cap Transfer In:").grid(row="8", column="0", sticky="e")
         self.addRow("capIn", "8")
     if settings.getCapDamageInSettings():
         tk.Label(self.innerFrame, text="Cap Warfare In:").grid(row="9", column="0", sticky="e")
         self.addRow("neutIn", "9")
     if settings.getMiningSettings():
         tk.Label(self.innerFrame, text="Mining:").grid(row="10", column="0", sticky="e")
         self.addRow("mining", "10")
     
     tk.Frame(self, height="20", width="1").grid(row="99", column="1", columnspan="5")
     
     buttonFrame = tk.Frame(self)
     buttonFrame.grid(row="100", column="0", columnspan="10")
     okButton = tk.Button(buttonFrame, text="  Run  ", command=self.doSimulation)
     okButton.grid(row="0", column="0")
     tk.Frame(buttonFrame, height="1", width="30").grid(row="0", column="1")
     cancelButton = tk.Button(buttonFrame, text="  Cancel  ", command=self.destroy)
     cancelButton.grid(row="0", column="2")
示例#2
0
    def __init__(self, parent, mainWindow, **kwargs):
        tk.Frame.__init__(self, parent, **kwargs)
        self.mainWindow = mainWindow

        self.scrollableCanvas = tk.Canvas(self, borderwidth=0, height="350")
        canvasFrame = tk.Frame(self.scrollableCanvas)
        scrollbar = tk.Scrollbar(self,
                                 orient="vertical",
                                 command=self.scrollableCanvas.yview)
        self.scrollableCanvas.configure(yscrollcommand=scrollbar.set)
        scrollbar.pack(side="right", fill="y")
        self.scrollableCanvas.pack(side="left", fill="both", expand=True)
        self.canvas_frame = self.scrollableCanvas.create_window(
            (0, 0), window=canvasFrame, anchor="nw")
        self.scrollableCanvas.bind("<Configure>", self.onCanvasResize)
        canvasFrame.columnconfigure(0, weight=1)
        canvasFrame.bind("<Configure>", self.onLineFrameConfigure)

        self.scrollableCanvas.bind('<Enter>', self.bindMousewheel)
        self.scrollableCanvas.bind('<Leave>', self.unbindMousewheel)

        dpsOutFrame = tk.Frame(canvasFrame)
        dpsOutFrame.grid(row="6",
                         column="0",
                         columnspan="5",
                         padx="5",
                         sticky="we")
        self.dpsOutSettings = settings.getDpsOutSettings()
        self.addLineSection(dpsOutFrame, "Outgoing: DPS", self.dpsOutSettings)

        dpsInFrame = tk.Frame(canvasFrame)
        dpsInFrame.grid(row="14",
                        column="0",
                        columnspan="5",
                        padx="5",
                        sticky="we")
        self.dpsInSettings = settings.getDpsInSettings()
        self.addLineSection(dpsInFrame, "Incoming: DPS", self.dpsInSettings)

        logiOutFrame = tk.Frame(canvasFrame)
        logiOutFrame.grid(row="8",
                          column="0",
                          columnspan="5",
                          padx="5",
                          sticky="we")
        self.logiOutSettings = settings.getLogiOutSettings()
        self.addLineSection(logiOutFrame, "Outgoing: logistics",
                            self.logiOutSettings)

        logiInFrame = tk.Frame(canvasFrame)
        logiInFrame.grid(row="16",
                         column="0",
                         columnspan="5",
                         padx="5",
                         sticky="we")
        self.logiInSettings = settings.getLogiInSettings()
        self.addLineSection(logiInFrame, "Incoming: logistics",
                            self.logiInSettings)

        capTransferedFrame = tk.Frame(canvasFrame)
        capTransferedFrame.grid(row="10",
                                column="0",
                                columnspan="5",
                                padx="5",
                                sticky="we")
        self.capTransferedSettings = settings.getCapTransferedSettings()
        self.addLineSection(capTransferedFrame, "Outgoing: capacitor transfer",
                            self.capTransferedSettings)

        capRecievedFrame = tk.Frame(canvasFrame)
        capRecievedFrame.grid(row="18",
                              column="0",
                              columnspan="5",
                              padx="5",
                              sticky="we")
        self.capRecievedSettings = settings.getCapRecievedSettings()
        self.addLineSection(capRecievedFrame,
                            "Incoming: capacitor transfer (including +nos)",
                            self.capRecievedSettings)

        capDamageOutFrame = tk.Frame(canvasFrame)
        capDamageOutFrame.grid(row="12",
                               column="0",
                               columnspan="5",
                               padx="5",
                               sticky="we")
        self.capDamageOutSettings = settings.getCapDamageOutSettings()
        self.addLineSection(capDamageOutFrame, "Outgoing: capacitor drain",
                            self.capDamageOutSettings)

        capDamageInFrame = tk.Frame(canvasFrame)
        capDamageInFrame.grid(row="20",
                              column="0",
                              columnspan="5",
                              padx="5",
                              sticky="we")
        self.capDamageInSettings = settings.getCapDamageInSettings()
        self.addLineSection(capDamageInFrame, "Incoming: capacitor drain",
                            self.capDamageInSettings)

        miningFrame = tk.Frame(canvasFrame)
        miningFrame.grid(row="22",
                         column="0",
                         columnspan="5",
                         padx="5",
                         sticky="we")
        self.miningSettings = settings.getMiningSettings()
        self.addLineSection(miningFrame,
                            "Mining",
                            self.miningSettings,
                            mining=True)
示例#3
0
 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
示例#4
0
    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
示例#5
0
 def __init__(self, mainWindow):
     tk.Toplevel.__init__(self)
     
     self.mainWindow = mainWindow
     self.graph = mainWindow.getGraph()
     self.animator = mainWindow.animator
     
     self.values = {}
     
     self.wm_attributes("-topmost", True)
     self.wm_title("PyEveLiveDPS 模拟设置")
     try:
         self.iconbitmap(sys._MEIPASS + '\\app.ico')
     except Exception:
         try:
             self.iconbitmap("app.ico")
         except Exception:
             pass
     self.geometry("400x120")
     self.update_idletasks()
     
     self.columnconfigure(0, weight=1)
     
     tk.Label(self, text="在每一轮中,每一项都会产生一个在你指定范围内的随机数。").grid(row="0", column="0", columnspan="10")
     
     tk.Frame(self, height="20", width="1").grid(row="1", column="1", columnspan="5")
     
     self.innerFrame = tk.Frame(self)
     self.innerFrame.grid(row="2", column="0")
     
     if settings.getDpsOutSettings():
         tk.Label(self.innerFrame, text="DPS输出量:").grid(row="2", column="0", sticky="e")
         self.addRow("dpsOut", "2")
     if settings.getLogiOutSettings():
         tk.Label(self.innerFrame, text="遥修输出量:").grid(row="3", column="0", sticky="e")
         self.addRow("logiOut", "3")
     if settings.getCapTransferedSettings():
         tk.Label(self.innerFrame, text="电容转移量:").grid(row="4", column="0", sticky="e")
         self.addRow("capOut", "4")
     if settings.getCapDamageOutSettings():
         tk.Label(self.innerFrame, text="电容吸收/中和输出量:").grid(row="5", column="0", sticky="e")
         self.addRow("neutOut", "5")
     if settings.getDpsInSettings():
         tk.Label(self.innerFrame, text="DPS遭受量:").grid(row="6", column="0", sticky="e")
         self.addRow("dpsIn", "6")
     if settings.getLogiInSettings():
         tk.Label(self.innerFrame, text="遥修接收量:").grid(row="7", column="0", sticky="e")
         self.addRow("logiIn", "7")
     if settings.getCapRecievedSettings():
         tk.Label(self.innerFrame, text="电容接收量:").grid(row="8", column="0", sticky="e")
         self.addRow("capIn", "8")
     if settings.getCapDamageInSettings():
         tk.Label(self.innerFrame, text="电容吸收/中和遭受量:").grid(row="9", column="0", sticky="e")
         self.addRow("neutIn", "9")
     if settings.getMiningSettings():
         tk.Label(self.innerFrame, text="采矿量:").grid(row="10", column="0", sticky="e")
         self.addRow("mining", "10")
     
     tk.Frame(self, height="20", width="1").grid(row="99", column="1", columnspan="5")
     
     buttonFrame = tk.Frame(self)
     buttonFrame.grid(row="100", column="0", columnspan="10")
     okButton = tk.Button(buttonFrame, text="  模拟  ", command=self.doSimulation)
     okButton.grid(row="0", column="0")
     tk.Frame(buttonFrame, height="1", width="30").grid(row="0", column="1")
     cancelButton = tk.Button(buttonFrame, text="  取消  ", command=self.destroy)
     cancelButton.grid(row="0", column="2")