diff --git a/setup.py b/setup.py index a7c4a6a..1877fc9 100644 --- a/setup.py +++ b/setup.py @@ -18,12 +18,11 @@ def apply_folder_join(item): return os.path.join(BIN_FOLDER, item) -if os.name is 'nt': +if os.name == 'nt': bin_scripts = ['symoro-bin.py'] else: bin_scripts = ['symoro-bin'] -bin_scripts = map(apply_folder_join, bin_scripts) - +bin_scripts = [apply_folder_join(x) for x in bin_scripts] setup( name='symoro', @@ -34,9 +33,9 @@ def apply_folder_join(item): scripts=bin_scripts, packages=find_packages(exclude=['*.tests', '*.tests.*', 'tests.*', 'tests']), install_requires=[ - 'sympy==0.7.3', + 'sympy>=0.7.3', 'numpy>=1.6.1', - 'wxPython>=2.8.11', + 'wxPython==4.0.7', 'PyOpenGL>=3.0.1b2' ], dependency_links=[ diff --git a/symoroui/layout.py b/symoroui/layout.py index a7bee01..2526bbb 100644 --- a/symoroui/layout.py +++ b/symoroui/layout.py @@ -121,13 +121,13 @@ def params_in_grid(self, szr_grd, elements, rows, cols, width=70): place = elements[key].place handler = getattr(self, elements[key].handler) field_id = int(elements[key].id) - if control is 'cmb': + if control == 'cmb': ctrl = wx.ComboBox( parent=self.panel, style=wx.CB_READONLY, size=(width, -1), name=name ) ctrl.Bind(wx.EVT_COMBOBOX, handler) - elif control is 'lbl': + elif control == 'lbl': ctrl = wx.StaticText( parent=self.panel, size=(width, -1), name=name ) diff --git a/symoroutils/configfile.py b/symoroutils/configfile.py index aab3cc6..d7bf0f9 100644 --- a/symoroutils/configfile.py +++ b/symoroutils/configfile.py @@ -28,7 +28,7 @@ def get_prog_config_path(): A string specifying the path to store SYMORO settings. """ prog_name = 'symoro' - if os.name is 'nt': + if os.name == 'nt': return os.path.join(os.environ['APPDATA'], prog_name) else: return os.path.join(os.environ['HOME'], '.config', prog_name) diff --git a/symoroviz/graphics.py b/symoroviz/graphics.py index 294a678..210974a 100644 --- a/symoroviz/graphics.py +++ b/symoroviz/graphics.py @@ -9,7 +9,7 @@ import wx import wx.lib.agw.floatspin as FS -from wx.glcanvas import GLCanvas +from wx.glcanvas import GLCanvas, GLContext import OpenGL.GL as gl import OpenGL.GLU as glu @@ -34,6 +34,7 @@ #TODO: Random button class VizGlCanvas(GLCanvas): + def __init__(self, parent, robo, params, size=(600, 600)): super(VizGlCanvas, self).__init__(parent, size=size) self.Bind(wx.EVT_PAINT, self.OnPaintAll) @@ -59,6 +60,8 @@ def __init__(self, parent, robo, params, size=(600, 600)): self.construct_hierarchy() self.dgms = {} self.l_solver = None + self._glContext = GLContext(self) + def OnEraseBackground(self, event): # Do nothing, to avoid flashing on MSW. @@ -140,8 +143,8 @@ def construct_hierarchy(self): def OnSize(self, event): size = self.size = self.GetClientSize() - if self.GetContext(): - self.SetCurrent() + if self._glContext: + self._glContext.SetCurrent(self) gl.glViewport(0, 0, size.width, size.height) #gl.glMatrixMode(gl.GL_PROJECTION) #gl.glLoadIdentity() @@ -244,7 +247,7 @@ def centralize_to_frame(self, index): self.Refresh(False) def OnPaintAll(self, event): - self.SetCurrent() + self._glContext.SetCurrent(self) if not self.init: self.InitGL() self.init = 1 @@ -469,7 +472,7 @@ def init_ui(self): choices.append("Frame " + str(jnt.index)) self.drag_pos = None self.clb_frames = wx.CheckListBox(self.p, choices=choices) - self.clb_frames.SetChecked(range(len(choices))) + self.clb_frames.SetCheckedItems(range(len(choices))) self.clb_frames.Bind(wx.EVT_CHECKLISTBOX, self.CheckFrames) self.clb_frames.Bind(wx.EVT_LISTBOX, self.SelectFrames) grd_szr_control.Add( @@ -573,7 +576,7 @@ def OnShowAllFrames(self, _): else: indices = [] self.canvas.show_frames(indices) - self.clb_frames.SetChecked(indices) + self.clb_frames.SetCheckedItems(indices) def update_spin_controls(self): for ctrl in self.spin_ctrls.values(): diff --git a/symoroviz/primitives.py b/symoroviz/primitives.py index c7bda5f..92c5900 100644 --- a/symoroviz/primitives.py +++ b/symoroviz/primitives.py @@ -9,6 +9,7 @@ from numpy import sin, cos, pi +import ctypes def create_cyl_array(radius, length, n_segments, centered=True): vertices, indices, normals = [], [], [] @@ -51,7 +52,7 @@ def create_sphere_array(radius, n_lat, n_long): normals += xn, yn, zn vertices += (x, y, z) # top and bottom indices - for i, start in enumerate([2, len(vertices)/3 - n_long]): + for i, start in enumerate([2, int(len(vertices)/3) - n_long]): for j in range(n_long): indices += (i, j + start, (j + 1) % n_long + start) # in-between