Saturday 15 June 2013

python - wxpython Pan implementation issue -


I am trying to implement a panning function in a wxpython program. This program contains a frame that contains a scroll window that has a bitmap image.

Clicking on the empty panel and panning generates expected behavior, clicking on the image and generating a 10px "jumping" about panning.

If the mouse_opo member is not updated while dragging, then the pencil is smooth on the image, but then the panning on the empty panel is wrong.

System Info: wxpython 2.8.12.1, Python 2.7.3 64bit and Windows 7 64bit.

  Import Import Import Threading Class Check MyFrame (wx.Frame): def __init __ (self, guardian, matil): wx.frame .__ init __ (self, guardian, wx. ID_ANY, mytitle, size = (350, 350)) self.scrollwin = wx.ScrolledWindow (self, WxkID_ANY) width = 1000 height = 1000 self.scrollwin.SetScrollbars (20, 20, width / 20, height / 20) Selfkskrollvinksetskrollrte (1, 1) Selfkskrollvinkbad (Vks.avt_moshn, Selfkon_maus_drag) Selfkskrollvinkbad (VCC. Avt_left_daun, Selfkon_left_daun) Selfksetkarsr (Vkskstokkrsor (Vkskkarsr_hand) ) image_file = "test.jpg" image = wx.Bitmap (image_file) sb = wx.StaticBitmap (self.scrollwin, wx.ID_ANY, image) Sb.Bind (wx.EVT_MOTION, self.event_defer) sb.Bind (wx. EVT_LEFT_DOWN, self.ev) (auto, value): "mouse_page:" print T: "Maus_poj:" Calling Print ":" Observe. () [1] [3] Print value self _mouse_pos = Value on df_mouse_project (self, event): if event. Dragging () and Events Left Insdaun (): self.sem Release () Print self.sem._Semaphore__value (mouse_x, mouse_y) = self.mouse_pos #new_pos = self.scrollwin.CalcUnscrolledPosition (event.GetPosition ()). (Go) #new_pos = self.scrollwin.CalcScrolledPosition (event.GetPosition (.)) Go () new_pos = event.GetPositionTuple () (new_x, new_y) = new_pos scrollpos = self.scrollwin.GetViewStart () (scroll_x, scroll_y) = scrollpos (delta_x, delta_y) = ((new_x - mouse_x), (new_y - mouse_y)) (scroll_x, scroll_y) = ((scroll_x - delta_x), (scroll_y - delta_y)) print "scroll" Print (scroll_x, scroll_y ) Self.scrollwin.Scroll (scroll_x, scroll_y) # self.mouse_pos = self.scrollwin.CalcUnscrolledPosition (event.GetPo ()). () #). Obtain yourself () #self.mouse_pos = self.scrollwin.CalcScrolledPosition (event.GetPosition ()). Get () self.mouse_pos = new_pos # Disabling this makes the image smooth panning at self.Sem.acquire (wrong) def on_left_down (auto, incident): # self.mouse_pos = self.scrollwin.CalcUnscrolledPosition (event.GetPosition () Go () #self.mouse_pos = self.scrollwin.CalcScrolledPosition (event.GetPosition ()) Go (..) Self.mouse_pos = event.GetPositionTuple () def event_defer (auto, event): event.ResumePropagation (1 ) Event.Skip () app = wx.App () MyFrame (none, "test wx.ScrolledWindow ()"). Show () app The main loop ()    

I got this accident, but I tried to run it and It looks great, no jumping when I'm panning an image around I'm running Python 2.7.3 at Ubuntu 12.04 (64bit), so there is probably a problem with Windows but it works on Linux.

No comments:

Post a Comment