Esempio n. 1
0
 def set(self, lo, hi):
     if float(lo) <= 0.0 and float(hi) >= 1.0:
         # grid_remove is currently missing from Tkinter!
         self.tk.call("grid", "remove", self)
     else:
         self.grid()
     Scrollbar.set(self, lo, hi)
Esempio n. 2
0
 def set(self, lo, hi):
     if float(lo) <= 0.0 and float(hi) >= 1.0:
         # grid_remove è attualmente assente da Tkinter.
         # Il metodo tk.call viene infatti richiamato sull'oggetto
         # scrollbar
         self.tk.call("grid", "remove", self)
     else:
         self.grid()
     Scrollbar.set(self, lo, hi)
Esempio n. 3
0
 def set(self, lo, hi):
     if float(lo) <= 0.0 and float(hi) >= 1.0:
         # grid_remove è attualmente assente da Tkinter.
         # Il metodo tk.call viene infatti richiamato sull'oggetto
         # scrollbar
         self.tk.call("grid", "remove", self)
     else:
         self.grid()
     Scrollbar.set(self, lo, hi)
Esempio n. 4
0
    def new_tab(self, event=None, filename=None, load_ext=True, ptype=None):
        """Create a new EditorPage and insert it into the notebook."""
        page_title = "#%d" % (len(self.text_notebook.pages) + 1)
        page = self.text_notebook.add_page(page_title)

        vbar = Scrollbar(page.frame, name='vbar')
        hbar = Scrollbar(page.frame, name='hbar', orient='horizontal')
        hbar.set(0, 0)
        vbar.set(0, 0)
        ptype = ptype or EditorPage
        page.editpage = ptype(page.frame, self, title=page_title,
            name='text', padx=5, wrap='none')

        firstpage = False # don't update window's title
        if self.menudict is None:
            # This EditorWindow is being created now, perform the following
            # tasks before.
            firstpage = True # will cause window's title to be updated
            self.menudict = {}
            self._createmenubar(page.editpage.text)
            # Create the recent files submenu
            self.recent_files_menu = Menu(self.menubar)
            self.menudict['file'].insert_cascade(3, label='Recent Files',
                underline=0, menu=self.recent_files_menu)
            self.update_recent_files_list()

        # pack widgets
        text = page.editpage.text
        vbar['command'] = text.yview
        hbar['command'] = text.xview
        text['yscrollcommand'] = vbar.set
        text['xscrollcommand'] = hbar.set
        vbar.pack(side=RIGHT, fill=Y)
        hbar.pack(side=BOTTOM, fill=X)
        fontWeight = 'normal'
        if idleConf.GetOption('main', 'EditorPage', 'font-bold', type='bool'):
            fontWeight = 'bold'
        text.config(font=(idleConf.GetOption('main', 'EditorPage', 'font'),
            idleConf.GetOption('main', 'EditorPage', 'font-size'),
            fontWeight))
        text.pack(side=TOP, fill=BOTH, expand=1)
        text.focus_set()

        self.apply_bindings(tab=page)
        if load_ext:
            self._load_extensions()

        # select the just created page
        self.text_notebook.select(len(self.text_notebook.pages) - 1)

        page.editpage.post_init(filename=filename,
            update_window_title=firstpage)

        self.top.event_generate('<<tab-created>>')
        return "break"
Esempio n. 5
0
class GcFrame(LabelFrame):
	def __init__(self, root, filename, contents, settings, logger, *arg):
		LabelFrame.__init__(self, root, *arg, text="gcode Viewer")

		self.label = Label(self)
		self.canvas = Canvas(self, width=settings.buildarea[0]*SCALE, height=settings.buildarea[1]*SCALE, bd=2, relief=RIDGE, bg="black")
		self.canvas.config(takefocus="1")
		self.root = root
		self.settings = settings
		self.buildarea = settings.buildarea
		self.log = logger
		self.zoom = 1
		self.offsetx = 0
		self.offsety = 0
		self.movestartx = 0
		self.movestarty = 0
		
		
		self.sb = Scrollbar(self)
		self.sb.config(command=self.scroll)
		self.sb.set(0.0, 1.0)
		self.sbslidersize = 1.0
		self.syncwithprint = IntVar()
		self.syncwithprint.set(1)
		self.bZoomOut = Button(self, text="-", width=3, command=self.doZoomOut)
		self.bZoomIn = Button(self, text="+", width=3, command=self.doZoomIn)
		self.cb = Checkbutton(self, text="Sync view with print", variable=self.syncwithprint,
			command=self.syncClick)
		self.bReset = Button(self, text="Reset View", command=self.pressReset)

		self.canvas.bind("<Button-1>", self.startMove);
		self.canvas.bind("<B1-Motion>", self.continueMove);
		self.canvas.bind("<MouseWheel>", self.mouseWheel);
		self.canvas.bind("<Button-4>", self.mouseWheel);
		self.canvas.bind("<Button-5>", self.mouseWheel);
		self.canvas.bind("<Shift-MouseWheel>", self.mouseWheelZoom);
		self.canvas.bind("<Shift-Button-4>", self.mouseWheelZoom);
		self.canvas.bind("<Shift-Button-5>", self.mouseWheelZoom);

		self.label.grid(row=1, column=1, columnspan=5)
		self.canvas.grid(row=2,column=1,columnspan=5)
		self.sb.grid(row=2, column=6, sticky=N+S)	
		self.bZoomOut.grid(row=3, column=1, sticky=E)
		self.bZoomIn.grid(row=3, column=2, sticky=W)
		self.cb.grid(row=3, column=3, columnspan=2)
		self.bReset.grid(row=3, column=5, columnspan=2)

		self.currentlayer = None
		self.currentdrawn = None
		self.currentlx = None
		self.layercount = 0
		self.filename = None
		self.printprogress = 0
		self.minline = 0
		self.maxline = 0
		
		self.drawGrid()

		self.model = Model()
		
		if filename != None:
			self.loadFile(filename, contents)
		
		#self.drawLayer(self.currentlayer)

	def getPrintStartLine(self):
		return self.model.getPrintStartLine()

	def pressReset(self):
		self.resetView()

	def startMove(self, e):
		self.canvas.focus_set()
		self.movestartx = e.x
		self.movestarty = e.y
		self.moveoffsetx = self.offsetx
		self.moveoffsety = self.offsety

	def continueMove(self, e):
		dx = e.x - self.movestartx
		dy = e.y - self.movestarty
		self.offsetx = self.moveoffsetx - dx/(2*self.zoom)
		self.offsety = self.moveoffsety - dy/(2*self.zoom)
		self.drawCanvas()
	
	def updatePrintProgress(self, n, restart=False):
		if n == 0:
			self.printprogress = 0
			if self.syncwithprint.get() == 1:
				if restart:
					self.currentLayer = self.model.bottomLayer()
					self.currentdrawn = None
					self.currentlx = 0
					self.setSliderPos()
				self.drawLayer(self.currentlayer)
			return
		
		if n <= self.printprogress:
			return

		ll = self.model.findLayersbyLineNo(self.printprogress, n)
		if len(ll) == 0: return

		self.printprogress = n		
		if self.syncwithprint.get() == 1:
			if self.currentlayer != ll[-1]:
				self.currentlayer = ll[-1]
				self.currentlx = self.model.getLayerNumber(self.currentlayer)
				self.drawLayer(self.currentlayer)
				self.setSliderPos()
			else:
				self.drawOneLayer(self.currentlayer, updateonly=True)
			
		else:
			if self.currentlayer in ll:
				self.drawOneLayer(self.currentlayer, updateonly=True)
		
	def scroll(self, *a):
		if self.currentlx == None:
			self.currentlx = 0
		
		if a[0] == "scroll":
			nlx = self.currentlx - int(a[1])
			if nlx < 0:
				nlx = 0
			elif nlx >= self.model.countLayers():
				nlx = self.model.countLayers()-1
				
		elif a[0] == "moveto":
			pos = 1.0 - float(a[1])
			nlx = int(pos / self.sbslidersize) - 1
			if nlx < 0:
				nlx = 0
			elif nlx >= self.model.countLayers():
				nlx = self.model.countLayers()-1
				
		else:
			return
	
		self.currentlx = nlx
		self.currentlayer = self.model.getLayerName(nlx)
		self.drawLayer(self.currentlayer)
		self.setSliderPos()
	
	def setSliderPos(self):
		if self.currentlx == None:
			self.currentlx = 0
		sbpos = 1.0 - (self.currentlx * self.sbslidersize) - self.sbslidersize
		if sbpos < 0.0:
			sbpos = 0.0
		self.sb.set(sbpos, sbpos+self.sbslidersize)

	def syncClick(self):
		if self.syncwithprint.get() == 1:
			self.updatePrintProgress(self.printprogress)
		
	def mouseWheel(self, e):
		if e.num == 5 or e.keycode == -120: #scroll down
			self.scroll("scroll", 1)
		elif e.num == 4 or e.keycode == 120: #scroll up
			self.scroll("scroll", -1)

	def mouseWheelZoom(self, e):
		if e.num == 5 or e.keycode == -120: #zoom in
			self.doZoomIn()

		elif e.num == 4 or e.keycode == 120: #zoom out
			if self.zoom > 1:
				self.doZoomOut()
				
	def doZoomIn(self):
		cw = self.buildarea[0]/self.zoom
		ch = self.buildarea[1]/self.zoom
		self.zoom += 1

		nw = self.buildarea[0]/self.zoom
		nh = self.buildarea[1]/self.zoom

		self.offsetx += (cw-nw)/2
		self.offsety += (ch-nh)/2
		self.drawCanvas()
	
	def doZoomOut(self):
		if self.zoom > 1:
			cw = self.buildarea[0]/self.zoom
			ch = self.buildarea[1]/self.zoom
			self.zoom -= 1
			if self.zoom < 1: self.zoom = 1

			nw = self.buildarea[0]/self.zoom
			nh = self.buildarea[1]/self.zoom

			self.offsetx -= (nw-cw)/2
			self.offsety -= (nh-ch)/2
			self.drawCanvas()

	def loadFile(self, filename, contents):
		self.filename = filename	
		self.model.addFile(contents)
		self.currentlayer = self.model.bottomLayer()
		self.currentlx = 0
		self.currentdrawn = None
		self.printprogress = 0
		self.layercount = self.model.countLayers()
			
		self.drawLayer(self.currentlayer)
	
		if self.layercount > 0:	
			self.sbslidersize = 1.0 / self.layercount
			self.setSliderPos()
			
	def getLayerNumberByHeight(self, z):
		return self.model.getLayerNumberByHeight(z)

	def resetView(self):
		self.zoom = 1
		self.offsety = 0
		self.offsetx = 0
		self.drawCanvas()

	def drawCanvas(self):
		self.currentdrawn = None
		self.drawGrid()
		self.drawLayer(self.currentlayer)
		self.setSliderPos()
			
	def drawGrid(self):
		self.canvas.delete("GRID")
		ltGrey = "#424242"
		dkGrey = "#404040"

		yleft = (0 - self.offsety)*self.zoom*SCALE
		if yleft < 0: yleft = 0

		yright = (self.buildarea[1] - self.offsety)*self.zoom*SCALE
		if yright > self.buildarea[1]*SCALE: yright = self.buildarea[1]*SCALE

		for x in range(0, self.buildarea[0], 10):
			if x%50 == 0:
				c = ltGrey
			else:
				c = dkGrey
			x = (x - self.offsetx)*self.zoom*SCALE
			if x >= 0 and x <= self.buildarea[0]*SCALE:
				self.canvas.create_line(x, yleft, x, yright, fill=c, tags="GRID")
			
		xtop = (0 - self.offsetx)*self.zoom*SCALE
		if xtop <0: xtop = 0

		xbottom = (self.buildarea[0] - self.offsetx)*self.zoom*SCALE
		if xbottom > self.buildarea[0]*SCALE: xbottom = self.buildarea[0]*SCALE

		for y in range(0, self.buildarea[1], 10):
			if y%50 == 0:
				c = dkGrey
			else:
				c = ltGrey
			y = (y - self.offsety)*self.zoom*SCALE
			if y >= 0 and y <= self.buildarea[1]*SCALE:
				self.canvas.create_line(xtop, y, xbottom, y, fill=c, tags="GRID")
			
	def drawLayer(self, layername):
		if layername == self.currentdrawn:
			#print "deleting object"
			#self.canvas.delete("OBJECT")
			self.drawOneLayer(layername, updateonly=True)
		else:
			self.canvas.delete("OBJECT")
			self.canvas.delete("SHADOW")
		
			pl = self.model.prevLayer(layername)
			if pl and self.settings.showprevious:
				self.drawOneLayer(pl, background=True)
			
			self.drawOneLayer(layername)
			self.currentdrawn = layername
		
	def drawOneLayer(self, layername, background=False, updateonly=False):
		if not self.model.setLayer(layername):
			return
		
		lx = self.model.getLayerNumber(layername)
		
		prev = [None, None]
		segmentextrusion = 0.0
		cx = 0
		segments = 0
		
		if background:
			tag = "SHADOW"
		else:
			tag = "OBJECT"

		if not background and not updateonly:
				self.label.config(text="file: %.30s    z = %.3f (%d/%d)" %
								(os.path.basename(self.filename), self.model.getLayerHeight(layername), lx+1, self.model.countLayers()))		
		for p in self.model:
			if prev == [None, None]:
				prev = [p[0], p[1]]
				if segments != 0:
					segments = 0
					cx = (cx + 1) % len(colors)
			else:
				if p[3] <= segmentextrusion or p[3] == -1:
					if p[3] == -1:
						segmentextrusion = 0.0

					if not updateonly:
						if not background and self.settings.showmoves:
							c = "white"	
							if prev != [p[0], p[1]]:
								(x1, y1) = self.transform(prev[0], self.buildarea[1]-prev[1])
								(x2, y2) = self.transform(p[0], self.buildarea[1]-p[1])
								self.canvas.create_line(x1, y1, x2, y2, fill=c, tags=tag)
						if segments != 0:
							segments = 0
							cx = (cx + 1) % len(colors)
				else:
					if prev != [p[0], p[1]]:
						segments += 1
						segmentextrusion = p[3]
						if background:
							c = grey
							f = not updateonly
						elif self.printprogress >= p[5]:
							c = "red"
							f = True
						else:
							c = colors[cx]
							f = not updateonly
						if f:
							(x1, y1) = self.transform(prev[0], self.buildarea[1]-prev[1])
							(x2, y2) = self.transform(p[0], self.buildarea[1]-p[1])
							self.canvas.create_line(x1, y1, x2, y2, fill=c, tags=tag)
				prev = [p[0], p[1]]

	def transform(self, ptx, pty):
		x = (ptx - self.offsetx)*self.zoom*SCALE
		y = (pty - self.offsety)*self.zoom*SCALE
		return (x, y)
Esempio n. 6
0
    def new_tab(self, event=None, filename=None, load_ext=True, ptype=None):
        """Create a new EditorPage and insert it into the notebook."""
        page_title = "#%d" % (len(self.text_notebook.pages) + 1)
        page = self.text_notebook.add_page(page_title)

        vbar = Scrollbar(page.frame, name='vbar')
        hbar = Scrollbar(page.frame, name='hbar', orient='horizontal')
        hbar.set(0, 0)
        vbar.set(0, 0)
        ptype = ptype or EditorPage
        page.editpage = ptype(page.frame,
                              self,
                              title=page_title,
                              name='text',
                              padx=5,
                              wrap='none')

        firstpage = False  # don't update window's title
        if self.menudict is None:
            # This EditorWindow is being created now, perform the following
            # tasks before.
            firstpage = True  # will cause window's title to be updated
            self.menudict = {}
            self._createmenubar(page.editpage.text)
            # Create the recent files submenu
            self.recent_files_menu = Menu(self.menubar)
            self.menudict['file'].insert_cascade(3,
                                                 label='Recent Files',
                                                 underline=0,
                                                 menu=self.recent_files_menu)
            self.update_recent_files_list()

        # pack widgets
        text = page.editpage.text
        vbar['command'] = text.yview
        hbar['command'] = text.xview
        text['yscrollcommand'] = vbar.set
        text['xscrollcommand'] = hbar.set
        vbar.pack(side=RIGHT, fill=Y)
        hbar.pack(side=BOTTOM, fill=X)
        fontWeight = 'normal'
        if idleConf.GetOption('main', 'EditorPage', 'font-bold', type='bool'):
            fontWeight = 'bold'
        text.config(
            font=(idleConf.GetOption('main', 'EditorPage', 'font'),
                  idleConf.GetOption('main', 'EditorPage', 'font-size'),
                  fontWeight))
        text.pack(side=TOP, fill=BOTH, expand=1)
        text.focus_set()

        self.apply_bindings(tab=page)
        if load_ext:
            self._load_extensions()

        # select the just created page
        self.text_notebook.select(len(self.text_notebook.pages) - 1)

        page.editpage.post_init(filename=filename,
                                update_window_title=firstpage)

        self.top.event_generate('<<tab-created>>')
        return "break"
Esempio n. 7
0
class ConditionalsEditor:
    def __init__(self, my_window, conditionals, close_callback):
        #Tk.__init__(self)
        self.my_window = my_window
        self.my_window.title("Condition Editor")
        self.close_callback = close_callback
        self.conditionals = conditionals

        shared_pad_x = 3
        shared_pad_y = 3

        main_frame = Frame(self.my_window)
        main_frame.grid(column=0, row=0, sticky=(N, W, E, S))
        image_path = "images"
        image_files = [
            f for f in os.listdir(image_path) if
            os.path.isfile(os.path.join(image_path, f)) and f.endswith(".png")
        ]
        self.icons = {}
        for image_file in image_files:
            self.icons[os.path.splitext(
                os.path.basename(image_file))[0]] = PhotoImage(
                    file=os.path.join(image_path, image_file))

        up_down_button_frame = Frame(main_frame)

        self.up_button = Button(up_down_button_frame,
                                state="disabled",
                                text="Move up",
                                image=self.icons["gtk-go-up"],
                                command=self.up_pressed)
        self.up_button.grid(column=0, row=0, sticky=(E))

        self.down_button = Button(up_down_button_frame,
                                  state="disabled",
                                  text="Move down",
                                  image=self.icons["gtk-go-down"],
                                  command=self.down_pressed)
        self.down_button.grid(column=0, row=1, sticky=(E))

        up_down_button_frame.grid(column=0, row=0, sticky=(E))

        condition_list = Frame(main_frame, relief=SUNKEN, borderwidth=1)
        condition_list.grid(column=1,
                            row=0,
                            sticky=(N, S, E, W),
                            padx=shared_pad_x,
                            pady=shared_pad_y,
                            columnspan=1)
        self.condition_list_scrollbar = Scrollbar(condition_list)

        self.state_listbox = Listbox(condition_list,
                                     relief=FLAT,
                                     exportselection=False,
                                     borderwidth=0,
                                     highlightthickness=0,
                                     yscrollcommand=self.state_listbox_scroll,
                                     activestyle="none")
        self.state_listbox.grid(column=0, row=0, padx=0, sticky=(N, S))
        self.state_listbox.bind("<<ListboxSelect>>",
                                self.state_listbox_selected)

        self.condition_listbox = Listbox(
            condition_list,
            relief=FLAT,
            exportselection=False,
            borderwidth=0,
            highlightthickness=0,
            yscrollcommand=self.condition_listbox_scroll,
            activestyle="none")
        self.condition_listbox.grid(column=1,
                                    row=0,
                                    sticky=(N, S, E, W),
                                    padx=0)
        self.condition_listbox.bind("<<ListboxSelect>>",
                                    self.condition_listbox_selected)

        self.execution_target_listbox = Listbox(
            condition_list,
            relief=FLAT,
            exportselection=False,
            borderwidth=0,
            highlightthickness=0,
            yscrollcommand=self.execution_target_listbox_scroll,
            activestyle="none")
        self.execution_target_listbox.grid(column=2,
                                           row=0,
                                           padx=0,
                                           sticky=(N, S))
        self.execution_target_listbox.bind(
            "<<ListboxSelect>>", self.execution_target_listbox_selected)

        self.condition_list_scrollbar.grid(column=3, row=0, sticky=(N, S))
        self.condition_list_scrollbar.config(
            command=self.condition_list_scrollbar_callback)
        condition_list.grid_rowconfigure(0, weight=1)

        for conditional in self.conditionals:
            self.state_listbox.insert(END, conditional[0])
            self.condition_listbox.insert(END, conditional[1])
            self.execution_target_listbox.insert(END, conditional[2])
        #for i in range(5):
        #    self.state_listbox.insert(END, "Foo %d"%i)
        #    self.condition_listbox.insert(END, "Bar %d"%i)
        #    self.execution_target_listbox.insert(END, "Baz %d"%i)

        if_label = Label(main_frame, text="If:", padx=10)
        if_label.grid(column=0, row=1, sticky=(N, E))
        self.if_text_variable = StringVar()
        if_entry = Entry(main_frame, textvariable=self.if_text_variable)
        if_entry.grid(
            column=1,
            row=1,
            sticky=(E, W),
            padx=shared_pad_x,
            pady=shared_pad_y,
        )

        then_label = Label(main_frame, text="Then:", padx=10)
        then_label.grid(column=0, row=2, sticky=(N, E))
        self.then_entry = Text(main_frame)
        self.then_entry.grid(
            column=1,
            row=2,
            sticky=(N, S, E, W),
            padx=shared_pad_x,
            rowspan=2,
        )

        option_frame = Frame(main_frame)
        execution_target_label = Label(option_frame, text="Execution target:")
        execution_target_label.grid(column=0,
                                    row=0,
                                    sticky=(N, W),
                                    pady=(10, shared_pad_y))
        self.execution_target = StringVar()
        self.execution_target.set("Debugger")
        debugger_radiobutton = Radiobutton(option_frame,
                                           text="Debugger",
                                           variable=self.execution_target,
                                           value="Debugger")
        debugger_radiobutton.grid(column=0, row=1, sticky=(N, W))
        python_radiobutton = Radiobutton(option_frame,
                                         text="Python",
                                         variable=self.execution_target,
                                         value="Python")
        python_radiobutton.grid(column=0, row=2, sticky=(N, W))
        state_label = Label(option_frame, text="State")
        state_label.grid(column=0,
                         row=3,
                         sticky=(N, W),
                         pady=(10, shared_pad_y))

        self.active_checkbutton = StringVar()
        self.active_checkbutton.set("Enabled")
        active_checkbutton = Checkbutton(option_frame,
                                         text="Enabled",
                                         variable=self.active_checkbutton,
                                         onvalue="Enabled",
                                         offvalue="Disabled")
        active_checkbutton.grid(column=0, row=4, sticky=(N, W))
        option_frame.grid(column=0, row=3, sticky=(N, S, E, W), pady=5)

        button_frame = Frame(main_frame)
        self.add_button = Button(button_frame,
                                 state="disabled",
                                 text="Add",
                                 image=self.icons["gtk-add"],
                                 compound=LEFT)
        self.add_button.grid(column=0, row=0, sticky=(E))
        self.update_button = Button(button_frame,
                                    state="disabled",
                                    text="Update",
                                    image=self.icons["gtk-edit"],
                                    compound=LEFT)
        self.update_button.grid(column=1, row=0, sticky=(E))
        self.delete_button = Button(button_frame,
                                    state="disabled",
                                    text="Delete",
                                    image=self.icons["gtk-remove"],
                                    compound=LEFT)
        self.delete_button.grid(column=2, row=0, sticky=(E))
        button_frame.grid(column=0,
                          row=4,
                          columnspan=2,
                          sticky=(E),
                          padx=shared_pad_x,
                          pady=shared_pad_y)

        close_frame = Frame(main_frame)
        close_button = Button(close_frame,
                              text="Close",
                              image=self.icons["gtk-close"],
                              compound=LEFT,
                              command=self.on_closing)
        close_button.grid(column=0, row=0, sticky=(S, E))
        close_frame.grid(column=0,
                         row=5,
                         columnspan=2,
                         sticky=(S, E),
                         padx=shared_pad_x,
                         pady=(15, shared_pad_y))

        self.my_window.grid_columnconfigure(0, weight=1)
        self.my_window.grid_rowconfigure(0, weight=1)
        main_frame.grid_columnconfigure(1, weight=1)
        main_frame.grid_rowconfigure(0, weight=1)
        main_frame.grid_rowconfigure(2, weight=0)
        main_frame.grid_rowconfigure(3, weight=1)
        main_frame.grid_rowconfigure(4, weight=1)
        main_frame.grid_rowconfigure(5, weight=1)
        condition_list.grid_columnconfigure(1, weight=1)
        button_frame.grid_rowconfigure(0, weight=1)

        self.my_window.protocol("WM_DELETE_WINDOW", self.on_closing)

    def on_closing(self):
        if self.close_callback is not None:
            self.close_callback()
        self.my_window.destroy()

    def up_pressed(self):
        index = self.state_listbox.curselection()[0]
        state_current = self.state_listbox.get(index)
        condition_current = self.condition_listbox.get(index)
        execution_target_current = self.execution_target_listbox.get(index)
        self.state_listbox.delete(index)
        self.condition_listbox.delete(index)
        self.execution_target_listbox.delete(index)
        self.state_listbox.insert(index - 1, state_current)
        self.condition_listbox.insert(index - 1, condition_current)
        self.execution_target_listbox.insert(index - 1,
                                             execution_target_current)

        self.conditionals.insert(index - 1, self.conditionals.pop(index))

        self.state_listbox.selection_set(index - 1)
        self.condition_listbox.selection_set(index - 1)
        self.execution_target_listbox.selection_set(index - 1)
        self.state_listbox.see(index - 1)

        if index - 1 == 0:
            self.up_button.config(state="disabled")
        self.down_button.config(state="normal")

    def down_pressed(self):
        index = self.state_listbox.curselection()[0]
        state_current = self.state_listbox.get(index)
        condition_current = self.condition_listbox.get(index)
        execution_target_current = self.execution_target_listbox.get(index)
        self.state_listbox.delete(index)
        self.condition_listbox.delete(index)
        self.execution_target_listbox.delete(index)
        self.state_listbox.insert(index + 1, state_current)
        self.condition_listbox.insert(index + 1, condition_current)
        self.execution_target_listbox.insert(index + 1,
                                             execution_target_current)

        self.conditionals.insert(index + 1, self.conditionals.pop(index))

        self.state_listbox.selection_set(index + 1)
        self.condition_listbox.selection_set(index + 1)
        self.execution_target_listbox.selection_set(index + 1)
        self.state_listbox.see(index + 1)

        if index + 1 == self.state_listbox.size() - 1:
            self.down_button.config(state="disabled")
        self.up_button.config(state="normal")

    def condition_list_scrollbar_callback(self, *args):
        self.state_listbox.yview(*args)
        self.condition_listbox.yview(*args)
        self.execution_target_listbox.yview(*args)

    def state_listbox_scroll(self, *args):
        self.condition_listbox.yview_moveto(args[0])
        self.execution_target_listbox.yview_moveto(args[0])
        self.condition_list_scrollbar.set(*args)

    def condition_listbox_scroll(self, *args):
        self.state_listbox.yview_moveto(args[0])
        self.execution_target_listbox.yview_moveto(args[0])

    def execution_target_listbox_scroll(self, *args):
        self.state_listbox.yview_moveto(args[0])
        self.condition_listbox.yview_moveto(args[0])

    def any_listbox_selected(self):
        self.up_button.config(state="normal")
        self.down_button.config(state="normal")
        if self.state_listbox.curselection(
        )[0] == self.state_listbox.size() - 1:
            self.down_button.config(state="disabled")
        if self.state_listbox.curselection()[0] == 0:
            self.up_button.config(state="disabled")
        self.delete_button.config(state="normal")
        self.then_entry.delete("1.0", END)
        self.then_entry.insert(
            END, self.conditionals[self.state_listbox.curselection()[0]][3])
        self.if_text_variable.set(
            self.conditionals[self.state_listbox.curselection()[0]][1])

        self.execution_target.set(
            self.conditionals[self.state_listbox.curselection()[0]][2])

        self.active_checkbutton.set(
            self.conditionals[self.state_listbox.curselection()[0]][0])

    def state_listbox_selected(self, event):
        index = self.state_listbox.curselection()[0]
        try:
            self.condition_listbox.selection_clear(
                self.condition_listbox.curselection()[0])
        except IndexError:
            pass
        self.condition_listbox.selection_set(index)
        try:
            self.execution_target_listbox.selection_clear(
                self.execution_target_listbox.curselection()[0])
        except IndexError:
            pass
        self.execution_target_listbox.selection_set(index)
        self.any_listbox_selected()

    def condition_listbox_selected(self, event):
        index = self.condition_listbox.curselection()[0]
        try:
            self.state_listbox.selection_clear(
                self.state_listbox.curselection()[0])
        except IndexError:
            pass
        self.state_listbox.selection_set(index)
        try:
            self.execution_target_listbox.selection_clear(
                self.execution_target_listbox.curselection()[0])
        except IndexError:
            pass
        self.execution_target_listbox.selection_set(index)
        self.any_listbox_selected()

    def execution_target_listbox_selected(self, event):
        index = self.execution_target_listbox.curselection()[0]
        try:
            self.state_listbox.selection_clear(
                self.state_listbox.curselection()[0])
        except IndexError:
            pass
        self.state_listbox.selection_set(index)
        try:
            self.condition_listbox.selection_clear(
                self.condition_listbox.curselection()[0])
        except IndexError:
            pass
        self.condition_listbox.selection_set(index)
        self.any_listbox_selected()