예제 #1
0
    def initUIGlobals(self):
        """
      This is the first part of the window to be rendered. After these have been
       set by the user and 'Emit Globals' has been clicked, the given algorithm
       can then specify how to generate the second part of the window. All fields
       are disabled for user input after globals have been emitted.

      Information in Global Parameters:
        Algorithm
          - name of the algorithm to use
        File Name
          - name of the output file to be generated
        Min Time
          - Minimum Time for distillers to run
        Max Time
          - Maximum Time for distillers to run
        Set Enabled:
          - checkbox to specify if the distiller should be enabled True or False
    """
        self.parent.title("Ini Generator")

        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        # initialize row counter. This is incremented after each element added to grid
        row = 0
        # initialize column counter. This is incremented after a column has been filled
        self.column = 0

        # Globals: entries for info common to all runs
        label_globals = Label(self, text="Globals")
        label_globals.grid(row=row, column=self.column)
        row += 1

        label_alg = Label(self, text="Algorithm")
        label_alg.grid(row=row, column=self.column, sticky=E + W)
        row += 1
        self.cbox_alg = Combobox(self,
                                 values=algorithms.keys(),
                                 state='readonly')
        self.cbox_alg.current(0)
        self.cbox_alg.grid(row=row, column=self.column, sticky=E + W + S + N)
        row += 1

        label_filename = Label(self, text="Output File Name")
        label_filename.grid(row=row, column=self.column, sticky=E + W)
        row += 1
        self.entry_filename = Entry(self)
        self.entry_filename.grid(row=row, column=self.column, sticky=W + E)
        row += 1

        label_mintime = Label(self, text="Min Time")
        label_mintime.grid(row=row, column=self.column, sticky=E + W)
        row += 1
        self.entry_mintime = Entry(self)
        self.entry_mintime.grid(row=row, column=self.column, sticky=W + E)
        row += 1

        label_maxtime = Label(self, text="Max Time")
        label_maxtime.grid(row=row, column=self.column, sticky=W + E)
        row += 1
        self.entry_maxtime = Entry(self)
        self.entry_maxtime.grid(row=row, column=self.column, sticky=W + E)
        row += 1

        self.enabled = IntVar()
        self.check_enabled = Checkbutton(self,
                                         text="set enabled",
                                         variable=self.enabled)
        self.check_enabled.grid(row=row, column=self.column, sticky=W + E)
        row += 1

        # Control: buttons used to emmiting text and generating file
        self.button_emit_globals = Button(self,
                                          text="Emit Globals",
                                          command=self.emit_globals)
        self.button_emit_globals.grid(row=row,
                                      column=self.column,
                                      sticky=W + E)
        row += 1

        button_addrun = Button(self, text="Add Run", command=self.emit_run)
        button_addrun.grid(row=row, column=self.column, sticky=W + E)
        row += 1

        button_generate = Button(self,
                                 text="Generate File",
                                 command=self.generate_file)
        button_generate.grid(row=row, column=self.column, sticky=W + E)
        row += 1

        self.column += 1

        self.pack()
from algorithm_fields import algorithms
from inigen import IniGen
import re
from uuid import UUID

gen = IniGen()

print "* * *     Welcome to the config file generation UI     * * *\n"
print "- - -     Global Settings     - - - "
prompt_text = 'Generated config file name: '
filename = raw_input(prompt_text)

prompt_text = ['Algorithm:']
for alg in algorithms.keys():
    prompt_text.append('\t- {0}'.format(alg))
prompt_text.append('-> ')
prompt_text = "\n".join(prompt_text)
while True:
    algorithm = raw_input(prompt_text)
    if algorithm not in algorithms.keys():
        print "Invalid algorithm. Select one from the list"
    else:
        break

prompt_text = 'Enabled (True or False): '
while True:
    enabled = raw_input(prompt_text)
    if enabled not in ['True', 'False']:
        print "Invalid boolean. Select 'True' or 'False'"
    else:
        break
from algorithm_fields import algorithms
from inigen import IniGen
import re
from uuid import UUID

gen = IniGen()

print "* * *     Welcome to the config file generation UI     * * *\n"
print "- - -     Global Settings     - - - "
prompt_text = 'Generated config file name: '
filename = raw_input(prompt_text)

prompt_text = ['Algorithm:']
for alg in algorithms.keys():
  prompt_text.append('\t- {0}'.format(alg))
prompt_text.append('-> ')
prompt_text = "\n".join(prompt_text)
while True:
  algorithm = raw_input(prompt_text)
  if algorithm not in algorithms.keys():
    print "Invalid algorithm. Select one from the list"
  else:
    break

prompt_text = 'Enabled (True or False): '
while True:
  enabled = raw_input(prompt_text)
  if enabled not in ['True', 'False']:
    print "Invalid boolean. Select 'True' or 'False'"
  else:
    break
  def initUIGlobals(self):
    """
      This is the first part of the window to be rendered. After these have been
       set by the user and 'Emit Globals' has been clicked, the given algorithm
       can then specify how to generate the second part of the window. All fields
       are disabled for user input after globals have been emitted.

      Information in Global Parameters:
        Algorithm
          - name of the algorithm to use
        File Name
          - name of the output file to be generated
        Min Time
          - Minimum Time for distillers to run
        Max Time
          - Maximum Time for distillers to run
        Set Enabled:
          - checkbox to specify if the distiller should be enabled True or False
    """
    self.parent.title("Ini Generator")

    Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

    # initialize row counter. This is incremented after each element added to grid
    row = 0
    # initialize column counter. This is incremented after a column has been filled
    self.column = 0

    # Globals: entries for info common to all runs
    label_globals = Label(self, text="Globals")
    label_globals.grid(row=row, column=self.column)
    row += 1

    label_alg = Label(self, text="Algorithm")
    label_alg.grid(row=row, column=self.column, sticky=E+W)
    row += 1
    self.cbox_alg = Combobox(self, values=algorithms.keys(), state='readonly')
    self.cbox_alg.current(0)
    self.cbox_alg.grid(row=row, column=self.column, sticky=E+W+S+N)
    row += 1

    label_filename = Label(self, text="Output File Name")
    label_filename.grid(row=row, column=self.column, sticky=E+W)
    row += 1
    self.entry_filename = Entry(self)
    self.entry_filename.grid(row=row, column=self.column, sticky=W+E)
    row += 1

    label_mintime = Label(self, text="Min Time")
    label_mintime.grid(row=row, column=self.column, sticky=E+W)
    row += 1
    self.entry_mintime = Entry(self)
    self.entry_mintime.grid(row=row, column=self.column, sticky=W+E)
    row += 1

    label_maxtime = Label(self, text="Max Time")
    label_maxtime.grid(row=row, column=self.column, sticky=W+E)
    row += 1
    self.entry_maxtime = Entry(self)
    self.entry_maxtime.grid(row=row, column=self.column, sticky=W+E)
    row += 1

    self.enabled = IntVar()
    self.check_enabled = Checkbutton(self, text="set enabled", variable=self.enabled)
    self.check_enabled.grid(row=row, column=self.column, sticky=W+E)
    row += 1

    # Control: buttons used to emmiting text and generating file
    self.button_emit_globals = Button(self, text="Emit Globals", command=self.emit_globals)
    self.button_emit_globals.grid(row=row, column=self.column, sticky=W+E)
    row += 1

    button_addrun = Button(self, text="Add Run", command=self.emit_run)
    button_addrun.grid(row=row, column=self.column, sticky=W+E)
    row += 1

    button_generate = Button(self, text="Generate File", command=self.generate_file)
    button_generate.grid(row=row, column=self.column, sticky=W+E)
    row += 1

    self.column += 1

    self.pack()