Commit e28c83c6 authored by Kliment Yanev's avatar Kliment Yanev

Fix listbox to no longer scroll horizontally

parent 1deb61b2
...@@ -16,7 +16,7 @@ class stlwrap: ...@@ -16,7 +16,7 @@ class stlwrap:
class showstl(wx.Window): class showstl(wx.Window):
def __init__(self,parent,size,pos): def __init__(self,parent,size,pos):
wx.Window.__init__(self,parent,size=size,pos=pos) wx.Window.__init__(self,parent,size=size,pos=pos)
self.l=wx.ListCtrl(self,style=wx.LC_LIST,size=(300,130),pos=(0,size[1]-130)) self.l=wx.ListBox(self,size=(300,130),pos=(0,size[1]-130))
self.eb=wx.Button(self,label="Export",pos=(300,size[1]-130)) self.eb=wx.Button(self,label="Export",pos=(300,size[1]-130))
self.sb=wx.Button(self,label="Snap to Z=0",pos=(300,size[1]-105)) self.sb=wx.Button(self,label="Snap to Z=0",pos=(300,size[1]-105))
self.cb=wx.Button(self,label="Put at 100,100",pos=(300,size[1]-80)) self.cb=wx.Button(self,label="Put at 100,100",pos=(300,size[1]-80))
...@@ -42,26 +42,26 @@ class showstl(wx.Window): ...@@ -42,26 +42,26 @@ class showstl(wx.Window):
self.prevsel=-1 self.prevsel=-1
def center(self,event): def center(self,event):
i=self.l.GetFirstSelected() i=self.l.GetSelection()
if i != -1: if i != -1:
m=self.models[self.l.GetItemText(i)] m=self.models[self.l.GetString(i)]
m.offsets=[100,100,m.offsets[2]] m.offsets=[100,100,m.offsets[2]]
self.Refresh() self.Refresh()
def snap(self,event): def snap(self,event):
i=self.l.GetFirstSelected() i=self.l.GetSelection()
if i != -1: if i != -1:
m=self.models[self.l.GetItemText(i)] m=self.models[self.l.GetString(i)]
m.offsets[2]=-1.0*min(m.facetsminz)[0] m.offsets[2]=-1.0*min(m.facetsminz)[0]
#print m.offsets[2] #print m.offsets[2]
self.Refresh() self.Refresh()
def delete(self,event): def delete(self,event):
i=self.l.GetFirstSelected() i=self.l.GetSelection()
if i != -1: if i != -1:
del self.models[self.l.GetItemText(i)] del self.models[self.l.GetString(i)]
self.l.DeleteItem(i) self.l.Delete(i)
self.l.Select(self.l.GetItemCount()-1) self.l.Select(self.l.GetCount()-1)
self.Refresh() self.Refresh()
def export(self,event): def export(self,event):
...@@ -179,24 +179,24 @@ class showstl(wx.Window): ...@@ -179,24 +179,24 @@ class showstl(wx.Window):
m.bitmap.SetMask(wx.Mask(m.bitmap,wx.Colour(0,0,0,255))) m.bitmap.SetMask(wx.Mask(m.bitmap,wx.Colour(0,0,0,255)))
#print time.time()-t #print time.time()-t
self.l.Append([stlwrap(self.models[newname],newname)]) self.l.Append(newname)
i=self.l.GetFirstSelected() i=self.l.GetSelection()
if i != -1: if i==wx.NOT_FOUND:
self.l.Select(i,0) self.l.Select(0)
self.l.Select(self.l.GetItemCount()-1) self.l.Select(self.l.GetCount()-1)
self.Refresh() self.Refresh()
#print time.time()-t #print time.time()-t
def move(self,event): def move(self,event):
if event.ButtonUp(wx.MOUSE_BTN_LEFT): if event.ButtonUp(wx.MOUSE_BTN_LEFT):
if(self.initpos is not None): if(self.initpos is not None):
i=self.l.GetFirstSelected() i=self.l.GetSelection()
if i != -1: if i != wx.NOT_FOUND:
p=event.GetPositionTuple() p=event.GetPositionTuple()
#print (p[0]-self.initpos[0]),(p[1]-self.initpos[1]) #print (p[0]-self.initpos[0]),(p[1]-self.initpos[1])
t=time.time() t=time.time()
m=self.models[self.l.GetItemText(i)] m=self.models[self.l.GetString(i)]
m.offsets=[m.offsets[0]+0.5*(p[0]-self.initpos[0]),m.offsets[1]-0.5*(p[1]-self.initpos[1]),m.offsets[2]] m.offsets=[m.offsets[0]+0.5*(p[0]-self.initpos[0]),m.offsets[1]-0.5*(p[1]-self.initpos[1]),m.offsets[2]]
#self.models[self.l.GetItemText(i)]=self.models[self.l.GetItemText(i)].translate([0.5*(p[0]-self.initpos[0]),0.5*(p[1]-self.initpos[1]),0]) #self.models[self.l.GetItemText(i)]=self.models[self.l.GetItemText(i)].translate([0.5*(p[0]-self.initpos[0]),0.5*(p[1]-self.initpos[1]),0])
#print time.time()-t #print time.time()-t
...@@ -220,10 +220,10 @@ class showstl(wx.Window): ...@@ -220,10 +220,10 @@ class showstl(wx.Window):
def rotateafter(self): def rotateafter(self):
if(self.i!=self.previ): if(self.i!=self.previ):
i=self.l.GetFirstSelected() i=self.l.GetSelection()
if i != -1: if i != wx.NOT_FOUND:
#o=self.models[self.l.GetItemText(i)].offsets #o=self.models[self.l.GetItemText(i)].offsets
self.models[self.l.GetItemText(i)].rot+=5*(self.i-self.previ) self.models[self.l.GetString(i)].rot+=5*(self.i-self.previ)
#self.models[self.l.GetItemText(i)].offsets=o #self.models[self.l.GetItemText(i)].offsets=o
self.previ=self.i self.previ=self.i
self.Refresh() self.Refresh()
...@@ -234,7 +234,7 @@ class showstl(wx.Window): ...@@ -234,7 +234,7 @@ class showstl(wx.Window):
def rot(self, event): def rot(self, event):
z=event.GetWheelRotation() z=event.GetWheelRotation()
s=self.l.GetFirstSelected() s=self.l.GetSelection()
if self.prevsel!=s: if self.prevsel!=s:
self.i=0 self.i=0
self.prevsel=s self.prevsel=s
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment