コード例 #1
0
class DesignBox(tk.Frame):
  # canvas is the model....
  canvas = None
  xscrollbar = None
  yscrollbar = None
  def __init__(self, master):
    tk.Frame.__init__(self, master)

    self.rowconfigure(0, weight = 1)
    self.columnconfigure(0, weight = 1)

    ## Add scrollbars for canvas
    self.xscrollbar = tk.Scrollbar(self, orient = tk.HORIZONTAL)
    self.xscrollbar.grid(row = 1, column = 0, sticky = sticky_all)
    self.yscrollbar = tk.Scrollbar(self, orient = tk.VERTICAL)
    self.yscrollbar.grid(row = 0, column = 1, sticky = sticky_all)

    self.canvas = ModelCanvas(self, mode = 'edit')
    self.canvas.grid(row = 0, column = 0, sticky = sticky_all)

    self.xscrollbar['command'] = self.canvas.xview
    self.yscrollbar['command'] = self.canvas.yview
    self.canvas.config(xscrollcommand = self.xscrollbar.set, yscrollcommand = self.yscrollbar.set)

    ## Set up event handlers
    self.bind_all('<<ModelSelect>>', self.handle_model_select)

  def switch_model(self, model):
    self.canvas.set_model(model)

  def handle_model_select(self, event):
    print 'modelselect'
    model = utils.event_data_retrieve(event.state)
    self.switch_model(model)
コード例 #2
0
ファイル: tools.py プロジェクト: jdaaph/rigid_body_designer
      def __init__(self, master, model = None):
        tk.Frame.__init__(self, master)
        self['bg'] = '#CCCCCC'

        self._model = model
        self.copies_var = tk.IntVar(self)

        self.columnconfigure(1, weight = 1)

        self.thumbnail = ModelCanvas(self, mode = 'view', model = model)
        self.thumbnail.configure(width = 100, height = 100)
        #self.thumbnail.set_model(model)
        self.thumbnail.padding = 5
        self.thumbnail.grid(row = 0, column = 0, sticky = sticky_all)

        self.copies_entry = tk.Entry(self, textvariable = self.copies_var)
        self.copies_entry.grid(row = 0, column = 1, sticky = tk.E + tk.W)
コード例 #3
0
  def __init__(self, master):
    tk.Frame.__init__(self, master)

    self.rowconfigure(0, weight = 1)
    self.columnconfigure(0, weight = 1)

    ## Add scrollbars for canvas
    self.xscrollbar = tk.Scrollbar(self, orient = tk.HORIZONTAL)
    self.xscrollbar.grid(row = 1, column = 0, sticky = sticky_all)
    self.yscrollbar = tk.Scrollbar(self, orient = tk.VERTICAL)
    self.yscrollbar.grid(row = 0, column = 1, sticky = sticky_all)

    self.canvas = ModelCanvas(self, mode = 'edit')
    self.canvas.grid(row = 0, column = 0, sticky = sticky_all)

    self.xscrollbar['command'] = self.canvas.xview
    self.yscrollbar['command'] = self.canvas.yview
    self.canvas.config(xscrollcommand = self.xscrollbar.set, yscrollcommand = self.yscrollbar.set)

    ## Set up event handlers
    self.bind_all('<<ModelSelect>>', self.handle_model_select)
コード例 #4
0
ファイル: tools.py プロジェクト: jdaaph/rigid_body_designer
    class ModelsListElement(tk.Frame):
      def __init__(self, master, model = None):
        tk.Frame.__init__(self, master)
        self['bg'] = '#CCCCCC'

        self._model = model
        self.copies_var = tk.IntVar(self)

        self.columnconfigure(1, weight = 1)

        self.thumbnail = ModelCanvas(self, mode = 'view', model = model)
        self.thumbnail.configure(width = 100, height = 100)
        #self.thumbnail.set_model(model)
        self.thumbnail.padding = 5
        self.thumbnail.grid(row = 0, column = 0, sticky = sticky_all)

        self.copies_entry = tk.Entry(self, textvariable = self.copies_var)
        self.copies_entry.grid(row = 0, column = 1, sticky = tk.E + tk.W)

        #self.bind_all('<<Model>>', lambda e: self.update_thumbnail(), add='+')

      @property
      def model(self):
      	return self._model
      @model.setter
      def model(self, m):
      	self.thumbnail.set_model(m)
      	self._model = m

      @property
      def copies(self):
      	return self.copies_var.get()
      @copies.setter
      def copies(self, num):
      	self.copies_var.set(num)

      def update_thumbnail(self):
        pass