Example #1
0
 def __init__(self, data):
     """Init the Spacecraft."""
     self.data = data
     self.subsections = {
         "Lifesupport": LifeSupport(data),
         "Propulsion": Propulsion(data),
         "Aux Thrusters": AuxThrusters(data),
         "Power Generation": PowerGeneration(data),
         "Radiators": Radiator(data, "Microtube Array"),
     }
     self.no_reactors = IntVar()
     self.mass_ratio = DoubleVar(value=3)
     self.mass_armor = DoubleVar()
     self.mass_defensive = DoubleVar()
     self.mass_cargo = DoubleVar()
     self.mass_other = DoubleVar()
     self.mass_lifesupport = QuantityVar(unit="g")
     self.mass_propulsion = QuantityVar(unit="g")
     self.mass_reactor = QuantityVar(unit="g")
     self.mass_aux_thrusters = QuantityVar(unit="g")
     self.mass_total_dry = QuantityVar(unit="g")
     self.mass_total_wet = QuantityVar(unit="g")
     self.mass_propellant = QuantityVar(unit="g")
     self.mass_H2O = QuantityVar(unit="g")
     self.mass_H3 = QuantityVar(unit="g")
     self.mass_D2 = QuantityVar(unit="g")
     self.sizes = Size(data)
     self.velocities = VelocityProfile(data)
Example #2
0
    def __init__(self, master):
        self.master = master
        master.title("SPACE Batch File Generator")

        Label(self.master, text= "Setting:").grid(row=0, column=0)
        Label(self.master, text= "Value:").grid(row=0, column=1)
        Label(self.master, text= "Vary Setting:").grid(row=0, column=2)
        
        self.rowCount = 1
        
        self.name = StringVar()
        self.seed = IntVar()
        self.timescale = IntVar()
        self.fluctuatingTimescale = BooleanVar()
        self.maxRunTime = IntVar()
        self.colonySize = StringVar()
        self.qThreshold = StringVar()
        self.pActive = DoubleVar()
        self.oldNestQ = DoubleVar()
        self.newNest1Q = DoubleVar()
        self.newNest2Q = DoubleVar()
        self.pheromones = BooleanVar()
        self.reverseTandem = BooleanVar()
        self.outTickRate = IntVar()
        self.outEmigration = BooleanVar()
        self.outColony = BooleanVar()
        self.outDeltas = BooleanVar()
        self.outStates = BooleanVar()
        self.outDetail = BooleanVar()
        self.outLegacy = BooleanVar()
        self.outDebug = BooleanVar()
        self.arenaFilePath = StringVar()
        
        self.addTextEntryToGrid("Base Experiment Name", self.name, False)
        self.addTextEntryToGrid("Random Seed", self.seed, True)
        self.addTextEntryToGrid("Starting Time Scale", self.timescale, True)
        self.addCheckButtonToGrid("Fluctuating Time Scale", self.fluctuatingTimescale, True)
        self.addTextEntryToGrid("Max Simulation Run Time (s)", self.maxRunTime, False)
        self.addTextEntryToGrid("Colony Size", self.colonySize, True)
        self.addTextEntryToGrid("Quorum Threshold", self.qThreshold, True)
        self.addTextEntryToGrid("Proportion Active", self.pActive, True)
        self.addTextEntryToGrid("Starting Nest Quality", self.oldNestQ, True)
        self.addTextEntryToGrid("First New Nest Quality", self.newNest1Q, True)
        self.addTextEntryToGrid("Second New Nest Quality", self.newNest2Q, True)
        self.addCheckButtonToGrid("Ants Lay Pheromones", self.pheromones, True)
        self.addCheckButtonToGrid("Ants Reverse Tandem Run", self.reverseTandem, True)
        self.addTextEntryToGrid("Output Tick Rate", self.outTickRate, False)
        self.addCheckButtonToGrid("Output Emigration Data", self.outEmigration, False)
        self.addCheckButtonToGrid("Output Colony Data", self.outColony, False)
        self.addCheckButtonToGrid("Output Ant Deltas", self.outDeltas, False)
        self.addCheckButtonToGrid("Output Ant State Distribution", self.outStates, False)
        self.addCheckButtonToGrid("Output Ant Detail", self.outDetail, False)
        self.addCheckButtonToGrid("Output Legacy Data", self.outLegacy, False)
        self.addCheckButtonToGrid("Output Ant Debug", self.outDebug, False)
        self.addTextEntryToGrid("Arena File Path", self.arenaFilePath, True)
        Button(master, text="Browse Arena Path", command=self.setArenaPath).grid(row=self.nextRow(), column=1, padx=5, pady=2)
        
        Button(master, text="Continue...", command=self.continueToNext, padx=50, pady=20).grid(row=self.nextRow(), column=0, columnspan=3, padx=15, pady=15, sticky='ew')
Example #3
0
 def __init__(self, parent, matches: Matches, column=1, row=1):
     super().__init__(parent, text=" Manual input ")
     self._matches = matches
     self._var_title = StringVar()
     self._var_ratio_1 = DoubleVar()
     self._var_ratio_x = DoubleVar()
     self._var_ratio_2 = DoubleVar()
     self.grid(column=column, row=row, sticky=NSEW, padx=PAD_X, pady=PAD_Y)
     self.create_widgets()
Example #4
0
    def init_catphan(self):

        def load_dir():
            f = filedialog.askdirectory()
            self.ct_file.set(f)

        def load_zip():
            f = filedialog.askopenfilename()
            self.ct_file.set(f)

        def analyze_cbct():
            if osp.isdir(self.ct_file.get()):
                cat = getattr(ct, self.ct_catphantype.get())(self.ct_file.get())
                fname = osp.join(self.ct_file.get(), 'CBCT Analysis.pdf')
            else:
                cat = getattr(ct, self.ct_catphantype.get()).from_zip(self.ct_file.get())
                fname = self.ct_file.get().replace('.zip', '.pdf')
            cat.analyze(hu_tolerance=self.ct_hu.get(), thickness_tolerance=self.ct_thickness.get(),
                        scaling_tolerance=self.ct_scaling.get())
            fname = utilities.file_exists(fname)
            cat.publish_pdf(fname)
            self.ct_pdf.set(fname)
            utilities.open_path(fname)

        self.ct_tab = Frame(self.notebook)
        self.ct_file = StringVar()
        self.ct_catphantype = StringVar()
        self.ct_hu = IntVar(value=40)
        self.ct_scaling = DoubleVar(value=1)
        self.ct_thickness = DoubleVar(value=0.2)
        self.ct_pdf = StringVar()
        Label(self.ct_tab, text='Load EITHER a directory or ZIP file').grid(column=2, row=1)
        Button(self.ct_tab, text='Load Directory...', command=load_dir).grid(column=2, row=2)
        Button(self.ct_tab, text='Load ZIP file...', command=load_zip).grid(column=2, row=3)
        Label(self.ct_tab, textvariable=self.ct_file).grid(column=2, row=4)
        Label(self.ct_tab, text='CatPhan type:').grid(column=2, row=5)
        Combobox(self.ct_tab, values=('CatPhan504', 'CatPhan503', 'CatPhan600', 'CatPhan604'), textvariable=self.ct_catphantype).grid(column=2, row=6)
        Label(self.ct_tab, text='HU Tolerance (HU):').grid(column=1, row=7)
        Entry(self.ct_tab, width=7, textvariable=self.ct_hu).grid(column=1, row=8)
        Label(self.ct_tab, text='Scaling tolerance (mm):').grid(column=2, row=7)
        Entry(self.ct_tab, width=7, textvariable=self.ct_scaling).grid(column=2, row=8)
        Label(self.ct_tab, text='Thickness tolerance (mm):').grid(column=3, row=7)
        Entry(self.ct_tab, width=7, textvariable=self.ct_thickness).grid(column=3, row=8)
        Button(self.ct_tab, text='Analyze', command=analyze_cbct).grid(column=2, row=9)
        Label(self.ct_tab,
              text='Analysis will analyze the file(s) according to the settings, \nsave a PDF in the same directory as the original file location and then open it.').grid(
            column=2, row=10)
        Label(self.ct_tab, text='Save file:').grid(column=2, row=11)
        Label(self.ct_tab, textvariable=self.ct_pdf).grid(column=2, row=12)
        self.notebook.add(self.ct_tab, text='CatPhan')
        for child in self.ct_tab.winfo_children():
            child.grid_configure(padx=10, pady=5)
Example #5
0
    def init_pf(self):

        def load_file():
            f = filedialog.askopenfilename()
            self.pf_file.set(f)

        def analyze_pf():
            mlc_type = self.pf_mlc.get()
            if self.pf_filter.get():
                pf = picketfence.PicketFence(self.pf_file.get(), mlc=mlc_type, filter=3)
            else:
                pf = picketfence.PicketFence(self.pf_file.get(), mlc=mlc_type)
            atol = self.pf_atol.get() if self.pf_atol.get() == 0 else None
            pickets = self.pf_pickets.get() if self.pf_pickets.get() == 0 else None
            pf.analyze(tolerance=self.pf_tol.get(),
                       action_tolerance=atol,
                       num_pickets=pickets,
                       )
            fname = osp.join(self.pf_file.get().replace('.dcm', '.pdf'))
            fname = utilities.file_exists(fname)
            pf.publish_pdf(fname)
            self.pf_pdf.set(fname)
            utilities.open_path(fname)

        self.pf_tab = Frame(self.notebook)
        self.pf_filter = BooleanVar(value=False)
        self.pf_file = StringVar()
        self.pf_tol = DoubleVar(value=0.5)
        self.pf_atol = DoubleVar(value=0.25)
        self.pf_pickets = IntVar(value=10)
        self.pf_pdf = StringVar()
        self.pf_mlc = StringVar()
        mlc_list = []
        for mlc in picketfence.MLC:
            mlc_list.append(mlc.value.get('name'))
        Checkbutton(self.pf_tab, text='Apply median filter', variable=self.pf_filter).grid(column=1, row=3)
        Button(self.pf_tab, text='Load File...', command=load_file).grid(column=1, row=1)
        Label(self.pf_tab, text='File:').grid(column=1, row=2)
        Label(self.pf_tab, textvariable=self.pf_file).grid(column=2, row=2)
        Label(self.pf_tab, text='Tolerance (mm):').grid(column=1, row=4)
        Entry(self.pf_tab, width=7, textvariable=self.pf_tol).grid(column=2, row=4)
        Label(self.pf_tab, text='Action Tolerance (mm):').grid(column=1, row=5)
        Entry(self.pf_tab, width=7, textvariable=self.pf_atol).grid(column=2, row=5)
        Label(self.pf_tab, text='Number of pickets:').grid(column=1, row=6)
        Entry(self.pf_tab, width=7, textvariable=self.pf_pickets).grid(column=2, row=6)
        Label(self.pf_tab, text='MLC type:').grid(column=1, row=7)
        Combobox(self.pf_tab, values=mlc_list, textvariable=self.pf_mlc, state='readonly').grid(column=2, row=7)
        Button(self.pf_tab, text='Analyze', command=analyze_pf).grid(column=1, row=8)
        Label(self.pf_tab, text='Analysis will analyze the file according to the settings, \nsave a PDF in the same directory as the original file location and then open it.').grid(column=1, row=9)
        self.notebook.add(self.pf_tab, text='Picket Fence')
        for child in self.pf_tab.winfo_children():
            child.grid_configure(padx=10, pady=5)
Example #6
0
	def __init__(self, master):

		pad = 3

		frame = Frame(master, padx=10, pady=10)
		frame.pack()

		button_dir = Button(frame, text="Set directory", command=self.get_directory)
		button_dir.grid(row=0, column=0, padx=pad, pady=pad*2, sticky='E')

		self.dir = StringVar()
		self.dir.set("No directory set!")
		Label(frame, textvariable=self.dir).grid(row=0, column=1, padx=pad, pady=pad, sticky='W')

		Label(frame, text="Overlay mode:").grid(row=1, column=0, padx=pad, pady=pad, sticky='E')
		self.mode = StringVar()
		self.mode.set("transparency")
		OptionMenu(frame, self.mode, "transparency", "multiply", "darken").grid(row=1, column=1, padx=pad, pady=pad, sticky='W')

		Label(frame, text="Blend factor:").grid(row=2, column=0, padx=pad, pady=pad, sticky='E')
		self.mix = DoubleVar()
		self.mix.set(0.8)
		Entry(frame, textvariable=self.mix).grid(row=2, column=1, padx=pad, pady=pad, sticky='W')

		Label(frame, text="Designs per generation:").grid(row=3, column=0, padx=pad, pady=pad, sticky='E')
		self.gen_size = IntVar()
		self.gen_size.set(100)
		Entry(frame, textvariable=self.gen_size).grid(row=3, column=1, padx=pad, pady=pad, sticky='W')

		Label(frame, text="Use nth generation:").grid(row=4, column=0, padx=pad, pady=pad, sticky='E')
		self.gen_stride = IntVar()
		self.gen_stride.set(1)
		Entry(frame, textvariable=self.gen_stride).grid(row=4, column=1, padx=pad, pady=pad, sticky='W')

		Label(frame, text="Use nth design:").grid(row=5, column=0, padx=pad, pady=pad, sticky='E')
		self.des_stride = IntVar()
		self.des_stride.set(1)
		Entry(frame, textvariable=self.des_stride).grid(row=5, column=1, padx=pad, pady=pad, sticky='W')

		Label(frame, text="Make index").grid(row=6, column=0, padx=pad, pady=pad, sticky='E')
		self.make_index = BooleanVar()
		self.make_index.set(True)
		Checkbutton(frame, variable=self.make_index).grid(row=6, column=1, padx=pad, pady=pad, sticky='W')

		Label(frame, text="Aspect:").grid(row=7, column=0, padx=pad, pady=pad, sticky='E')
		self.aspect = DoubleVar()
		self.aspect.set(2.0)
		Entry(frame, textvariable=self.aspect).grid(row=7, column=1, padx=pad, pady=pad, sticky='W')

		self.button_run = Button(frame, text="Run", command=self.run_app)
		self.button_run.grid(row=8, columnspan=2, padx=pad*2, pady=10)
Example #7
0
    def add_vectors(self):
        self.clear()
        num_vectors = DoubleVar()
        dimension = DoubleVar()
        num_vectors.set(2)
        dimension.set(2)

        num_vectors_entry = Entry(mainframe,
                                  width=5,
                                  textvariable=num_vectors,
                                  font=MATRIX_FONT)
        num_vectors_entry.grid(column=1, row=2, sticky=W)
        dimension_entry = Entry(mainframe,
                                width=5,
                                textvariable=dimension,
                                font=MATRIX_FONT)
        dimension_entry.grid(column=1, row=3, sticky=W)

        num_vectors_label = Label(mainframe, text="vectors", font=LABEL_FONT)
        num_vectors_label.grid(column=2, row=2, sticky=E)
        dimension_label = Label(mainframe, text="dimensions", font=LABEL_FONT)
        dimension_label.grid(column=2, row=3, sticky=E)

        def add_vectors_input():
            try:
                num_vectors_value = num_vectors.get()
                dimension_value = dimension.get()
                if 2 <= num_vectors_value <= 15 and 2 <= dimension_value <= 15 and num_vectors_value % 1 == 0 and dimension_value % 1 == 0:
                    self.vectors_input(int(num_vectors_value),
                                       int(dimension_value), ADD_VECTORS)
                else:
                    raise ValueError
            except ValueError:
                messagebox.showerror(
                    "Error",
                    "Number of vectors or dimensions must be between 2 and 15")
            except TclError:
                messagebox.showerror("Error", "Invalid input")
                return

        submit = Button(mainframe,
                        text="Submit",
                        command=add_vectors_input,
                        font=LABEL_FONT)
        submit.grid(column=1, row=4, columnspan=2, sticky=W)
        dimension_header = Label(
            mainframe,
            text="Enter the number of vectors to add and their dimensions:",
            font=LABEL_FONT)
        dimension_header.grid(column=1, row=1, columnspan=FILL, sticky=W)
Example #8
0
    def init_tg51(self):

        self.tg_tab = Frame(self.notebook)
        self.tg_pdf = StringVar()
        self.tg_temp = DoubleVar(value=22)
        self.tg_press = DoubleVar(value=760)
        r, r2 = itertools.count(), itertools.count()
        Label(self.tg_tab, text='Temperature (C):').grid(column=1, row=next(r))
        Entry(self.tg_tab, width=7, textvariable=self.tg_temp).grid(column=2, row=next(r2))
        Label(self.tg_tab, text='Pressure (mmHg):').grid(column=1, row=next(r))
        Entry(self.tg_tab, width=7, textvariable=self.tg_press).grid(column=2, row=next(r2))
        self.notebook.add(self.tg_tab, text='TG-51')
        for child in self.tg_tab.winfo_children():
            child.grid_configure(padx=10, pady=5)
Example #9
0
    def systems(self):
        self.clear()
        var = DoubleVar()
        eq = DoubleVar()
        var.set(2)
        eq.set(2)

        var_entry = Entry(mainframe,
                          width=5,
                          textvariable=var,
                          font=MATRIX_FONT)
        var_entry.grid(column=1, row=2, sticky=W)
        eq_entry = Entry(mainframe, width=5, textvariable=eq, font=MATRIX_FONT)
        eq_entry.grid(column=1, row=3, sticky=W)

        var_label = Label(mainframe, text="variables (2-10)", font=LABEL_FONT)
        var_label.grid(column=2, row=2, sticky=E)
        eq_label = Label(mainframe, text="equations (2-10)", font=LABEL_FONT)
        eq_label.grid(column=2, row=3, sticky=E)

        def systems_input():
            try:
                var_value = var.get()
                eq_value = eq.get()
                if 2 <= var_value <= 10 and 2 <= eq_value <= 10 and var_value % 1 == 0 and eq_value % 1 == 0:
                    self.matrix_input(int(eq_value),
                                      int(var_value) + 1, SYSTEMS)
                else:
                    raise ValueError
            except ValueError:
                messagebox.showerror(
                    "Error",
                    "Number of variables or equations must be between 2 and 10"
                )
            except TclError:
                messagebox.showerror("Error", "Invalid input")
                return

        submit = Button(mainframe,
                        text="Submit",
                        command=systems_input,
                        font=LABEL_FONT)
        submit.grid(column=1, row=4, columnspan=2, sticky=W)
        dimension_header = Label(
            mainframe,
            text="Enter the number of variables and equations:",
            font=LABEL_FONT)
        dimension_header.grid(column=1, row=1, columnspan=4, sticky=W)
Example #10
0
    def rref(self):
        self.clear()
        rows = DoubleVar()
        columns = DoubleVar()
        rows.set(2)
        columns.set(2)

        row_entry = Entry(mainframe,
                          width=5,
                          textvariable=rows,
                          font=MATRIX_FONT)
        row_entry.grid(column=1, row=2, sticky=W)
        column_entry = Entry(mainframe,
                             width=5,
                             textvariable=columns,
                             font=MATRIX_FONT)
        column_entry.grid(column=1, row=3, sticky=W)

        row_label = Label(mainframe, text="rows", font=LABEL_FONT)
        row_label.grid(column=2, row=2, sticky=E)
        column_label = Label(mainframe, text="columns", font=LABEL_FONT)
        column_label.grid(column=2, row=3, sticky=E)

        def rref_input():
            try:
                row_value = rows.get()
                column_value = columns.get()
                if 2 <= row_value <= 15 and 2 <= column_value <= 15 and row_value % 1 == 0 and column_value % 1 == 0:
                    self.matrix_input(int(row_value), int(column_value), RREF)
                else:
                    raise ValueError
            except ValueError:
                messagebox.showerror("Error",
                                     "Matrix must be between 2x2 and 15x15")
            except TclError:
                messagebox.showerror("Error", "Invalid input")
                return

        submit = Button(mainframe,
                        text="Submit",
                        command=rref_input,
                        font=LABEL_FONT)
        submit.grid(column=1, row=4, columnspan=2, sticky=W)
        dimension_header = Label(
            mainframe,
            text="Enter the dimensions of the matrix (2x2 - 15x15):",
            font=LABEL_FONT)
        dimension_header.grid(column=1, row=1, columnspan=4, sticky=W)
    def __init__(self, container, *args, **kwargs):
        """
        Constructor.

        :param tkinter.Frame container: reference to container frame
        """

        self._baudrates_vals = kwargs.pop("baudrates", BAUDRATES)
        self._databits_vals = kwargs.pop("databits", DATABITS)
        self._stopbits_vals = kwargs.pop("stopbits", STOPBITS)
        self._parities_vals = kwargs.pop("parities", PARITIES)
        self._preselect = kwargs.pop("preselect", ())
        self._readonlybg = kwargs.pop("readonlybackground", BGCOL)

        Frame.__init__(self, container, *args, **kwargs)

        self._show_advanced = False
        self._noports = True
        self._ports = ()
        self._port = StringVar()
        self._port_desc = StringVar()
        self._baudrate = IntVar()
        self._databits = IntVar()
        self._stopbits = DoubleVar()
        self._parity = StringVar()
        self._rtscts = IntVar()
        self._xonxoff = IntVar()

        self._body()
        self._do_layout()
        self._get_ports()
        self._attach_events()
        self.reset()
Example #12
0
 def __init__(self, root):
     self.data = [DoubleVar(root, name=str(index)) for index in range(81)]
     self.possible_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]
     self.editting_now = []
     self.buttons = []
     self.board_answer = []
     self.correction = False