_vios avatar _vios committed aaa162b

選択開始位置と終了位置を自動で区別するようにした,リストボックスをダブルクリックすると区間選択できるようにした

Comments (0)

Files changed (1)

         self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
         self.sizer3 = wx.BoxSizer(wx.HORIZONTAL)
 
-        self.buttonStart = wx.Button(self,label=u"開始ページ指定")
-        self.buttonEnd = wx.Button(self,label=u"終了ページ指定")
+        self.buttonStart = wx.Button(self,label=u"区間指定")
+        #self.buttonEnd = wx.Button(self,label=u"終了ページ指定")
         self.buttonCancel = wx.Button(self,label=u"指定取り消し")
         self.buttonZip = wx.Button(self,label=u"圧縮開始")
         self.buttonFree = wx.Button(self,label=u"フォルダ選択解除")
         self.buttonDelete = wx.Button(self,label=u"オリジナルファイルの削除")
         self.sizer2.Add(self.buttonStart,1,wx.EXPAND)
-        self.sizer2.Add(self.buttonEnd,1,wx.EXPAND)
+        #self.sizer2.Add(self.buttonEnd,1,wx.EXPAND)
         self.sizer2.Add(self.buttonCancel,1,wx.EXPAND)
         self.sizer2.Add(self.buttonZip,1,wx.EXPAND)
         self.sizer3.Add(self.buttonFree,1,wx.EXPAND)
         self.sizer3.Add(self.buttonDelete,1,wx.EXPAND)
         self.buttonStart.Bind(wx.EVT_BUTTON,self.selectStart)
-        self.buttonEnd.Bind(wx.EVT_BUTTON,self.selectEnd)
+        #self.buttonEnd.Bind(wx.EVT_BUTTON,self.selectEnd)
         self.buttonCancel.Bind(wx.EVT_BUTTON,self.selectCancel)
         self.buttonZip.Bind(wx.EVT_BUTTON,self.selectZip)
         self.buttonFree.Bind(wx.EVT_BUTTON,self.selectFree)
         startPath = None
         endPath = None
 
+    def setStart(self,index,path):
+        global startPath,startIndex
+        startIndex = index
+        startPath = path
+        startStr.SetLabel("start: " + os.path.basename(startPath))
+    def setEnd(self,index,path):
+        global endPath,endIndex
+        endIndex = index
+        endPath = path
+        endStr.SetLabel("end: " + os.path.basename(endPath))
+  
 
+    #need to cheange 
     def selectStart(self,e):
-        global startPath,startIndex
+        global startIndex,endIndex
         print flist[fileList.GetSelections()[0]]
-        startIndex = fileList.GetSelections()[0]
-        startPath = flist[fileList.GetSelections()[0]]
-        startStr.SetLabel("start: " + os.path.basename(startPath))
+        selectedIndex = fileList.GetSelections()[0]
+        selectedPath = flist[fileList.GetSelections()[0]]
+        #開始も終了位置も選択されていない場合
+        if startIndex == None and endIndex == None:
+            self.setStart(selectedIndex,selectedPath)
+        #開始位置だけ選択されている場合
+        elif startIndex != None and endIndex == None:
+            if selectedIndex >= startIndex:
+                self.setEnd(selectedIndex,selectedPath)
+            else:
+                endIndex = startIndex
+                self.setEnd(endIndex,flist[endIndex])
+                self.setStart(selectedIndex,selectedPath)
+        #終了位置だけ選択されている場合(ありえないと思うので未実装)
+        elif startIndex == None and endIndex != None:
+            print u"エラー:想定外の選択です"
+        #開始,終了どちらも選択済みの場合
+        else:
+            if selectedIndex > endIndex:
+                self.setEnd(selectedIndex,selectedPath)
+                return
+            elif selectedIndex < startIndex:
+                self.setStart(selectedIndex,selectedPath)
+                return
+
+            dialog = wx.MessageDialog(None,u"Yesなら開始位置に,Noなら終了位置に設定します",
+                    u"開始位置か終了位置かを選んでください",
+                    wx.YES_NO | wx.ICON_QUESTION)
+            if dialog.ShowModal() == wx.ID_YES:
+                self.setStart(selectedIndex,selectedPath)
+            else:
+                self.setEnd(selectedIndex,selectedPath)
+            dialog.Destroy()
+
+
+
+
+
+
+    """
     def selectEnd(self,e):
         global endPath,endIndex
         print flist[fileList.GetSelections()[0]]
         endIndex = fileList.GetSelections()[0]
         endPath = flist[fileList.GetSelections()[0]]
         endStr.SetLabel("end: " + os.path.basename(endPath))
+    """
     def selectCancel(self,e):
         global startPath,endPath,startIndex,endIndex
         startStr.SetLabel("start: ")
         self.fileList.SetItemBackgroundColour(fileList.GetSelections()[0],wx.Colour(0,255,255))
         self.fileList.Refresh()
         print "dclicked"
+        self.selectStart(e)
 
     def selectDelete(self,e):
         global dirPath
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.