Advertisement
Koragg

Load Image(s) {local & URL} [Python 3.6]

Jun 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. import wx, requests, urllib.request
  2.  
  3. class Test(wx.Frame):
  4.     def __init__(self, parent, id):
  5.         wx.Frame.__init__(self, parent, id, "Test App", (800, 800))
  6.         self.panel = wx.Panel(self)
  7.         self.panel.SetBackgroundColour("#FFFFFF")
  8.         self.Centre()
  9.         #show local image
  10.         '''self.image = wx.Image("Untitled.png", wx.BITMAP_TYPE_ANY)
  11.         self.imageBitmap = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.Bitmap(self.image))'''
  12.         #show image from URL
  13.         self.URL = "https://maps.googleapis.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318"
  14.         urllib.request.urlretrieve(self.URL, "image.jpg")
  15.         self.image = wx.Image("image.jpg", wx.BITMAP_TYPE_ANY)
  16.         self.imageBitmap = wx.StaticBitmap(self.panel, wx.ID_ANY, wx.Bitmap(self.image))
  17.  
  18. def main():
  19.     app = wx.App()
  20.     frame = Test(None, -1)
  21.     frame.Show()
  22.     app.MainLoop()
  23.  
  24. if __name__ == "__main__":
  25.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement