Mercurial > traipse_dev
comparison orpg/mapper/background_handler.py @ 19:78407d627cba traipse_dev
Beginning of Code Clean-up. Some code untested, may break!
author | sirebral |
---|---|
date | Sat, 25 Jul 2009 17:24:40 -0500 |
parents | 0b8b7e3ed78d |
children | 072ffc1d466f |
comparison
equal
deleted
inserted
replaced
18:67b900deb35c | 19:78407d627cba |
---|---|
50 self.url_path = wx.TextCtrl(self, wx.ID_ANY,"http://") | 50 self.url_path = wx.TextCtrl(self, wx.ID_ANY,"http://") |
51 self.color_button = wx.Button(self, wx.ID_ANY, "Color", style=wx.BU_EXACTFIT) | 51 self.color_button = wx.Button(self, wx.ID_ANY, "Color", style=wx.BU_EXACTFIT) |
52 self.color_button.SetBackgroundColour(wx.BLACK) | 52 self.color_button.SetBackgroundColour(wx.BLACK) |
53 self.color_button.SetForegroundColour(wx.WHITE) | 53 self.color_button.SetForegroundColour(wx.WHITE) |
54 self.apply_button = wx.Button(self, wx.ID_ANY, "Apply", style=wx.BU_EXACTFIT) | 54 self.apply_button = wx.Button(self, wx.ID_ANY, "Apply", style=wx.BU_EXACTFIT) |
55 """ | |
56 self.sizer.Add(self.bg_type, 0, wx.EXPAND) | |
57 self.sizer.Add(self.url_path, 1, wx.EXPAND) | |
58 self.sizer.Add(self.color_button, 0, wx.EXPAND) | |
59 self.sizer.Add(self.localBrowse, 0, wx.EXPAND) | |
60 self.sizer.Add(self.apply_button, 0, wx.EXPAND) | |
61 """ | |
62 | |
63 self.sizer.Add(self.bg_type, 0, wx.ALIGN_CENTER) | 55 self.sizer.Add(self.bg_type, 0, wx.ALIGN_CENTER) |
64 self.sizer.Add((6, 0)) | 56 self.sizer.Add((6, 0)) |
65 self.sizer.Add(self.url_path, 1, wx.ALIGN_CENTER) | 57 self.sizer.Add(self.url_path, 1, wx.ALIGN_CENTER) |
66 self.sizer.Add((6, 0)) | 58 self.sizer.Add((6, 0)) |
67 self.sizer.Add(self.color_button, 0, wx.ALIGN_CENTER) | 59 self.sizer.Add(self.color_button, 0, wx.ALIGN_CENTER) |
68 self.sizer.Add((6, 0)) | 60 self.sizer.Add((6, 0)) |
69 self.sizer.Add(self.localBrowse, 0, wx.ALIGN_CENTER) | 61 self.sizer.Add(self.localBrowse, 0, wx.ALIGN_CENTER) |
70 self.sizer.Add((6, 0)) | 62 self.sizer.Add((6, 0)) |
71 self.sizer.Add(self.apply_button, 0, wx.ALIGN_CENTER) | 63 self.sizer.Add(self.apply_button, 0, wx.ALIGN_CENTER) |
72 | |
73 self.Bind(wx.EVT_BUTTON, self.on_bg_color, self.color_button) | 64 self.Bind(wx.EVT_BUTTON, self.on_bg_color, self.color_button) |
74 self.Bind(wx.EVT_BUTTON, self.on_apply, self.apply_button) | 65 self.Bind(wx.EVT_BUTTON, self.on_apply, self.apply_button) |
75 self.Bind(wx.EVT_BUTTON, self.on_browse, self.localBrowse) | 66 self.Bind(wx.EVT_BUTTON, self.on_browse, self.localBrowse) |
76 self.Bind(wx.EVT_CHOICE, self.on_bg_type, self.bg_type) | 67 self.Bind(wx.EVT_CHOICE, self.on_bg_type, self.bg_type) |
77 self.update_info() | 68 self.update_info() |
78 | 69 |
79 def on_browse(self, evt): | 70 def on_browse(self, evt): |
80 if self.bg_type.GetStringSelection() == 'Texture' or self.bg_type.GetStringSelection() == 'Image': | 71 if self.bg_type.GetStringSelection() == 'Texture' or self.bg_type.GetStringSelection() == 'Image': |
81 dlg = wx.FileDialog(None, "Select a Miniature to load", orpg.dirpath.dir_struct["user"]+'webfiles/', wildcard="Image files (*.bmp, *.gif, *.jpg, *.png)|*.bmp;*.gif;*.jpg;*.png", style=wx.OPEN) | 72 dlg = wx.FileDialog(None, "Select a Miniature to load", |
73 orpg.dirpath.dir_struct["user"]+'webfiles/', | |
74 wildcard="Image files (*.bmp, *.gif, *.jpg, *.png)|*.bmp;*.gif;*.jpg;*.png", style=wx.OPEN) | |
82 if not dlg.ShowModal() == wx.ID_OK: | 75 if not dlg.ShowModal() == wx.ID_OK: |
83 dlg.Destroy() | 76 dlg.Destroy() |
84 return | 77 return |
85 file = open(dlg.GetPath(), "rb") | 78 file = open(dlg.GetPath(), "rb") |
86 imgdata = file.read() | 79 imgdata = file.read() |
88 filename = dlg.GetFilename() | 81 filename = dlg.GetFilename() |
89 (imgtype,j) = mimetypes.guess_type(filename) | 82 (imgtype,j) = mimetypes.guess_type(filename) |
90 postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype}) | 83 postdata = urllib.urlencode({'filename':filename, 'imgdata':imgdata, 'imgtype':imgtype}) |
91 | 84 |
92 if self.settings.get_setting('LocalorRemote') == 'Remote': | 85 if self.settings.get_setting('LocalorRemote') == 'Remote': |
93 thread.start_new_thread(self.canvas.layers['bg'].upload, (postdata, dlg.GetPath(), self.bg_type.GetStringSelection())) | 86 thread.start_new_thread(self.canvas.layers['bg'].upload, |
87 (postdata, dlg.GetPath(), self.bg_type.GetStringSelection())) | |
94 else: | 88 else: |
95 try: | 89 try: |
96 min_url = open_rpg.get_component("cherrypy") + filename | 90 min_url = open_rpg.get_component("cherrypy") + filename |
97 except: | 91 except: |
98 return | 92 return |
99 min_url = dlg.GetDirectory().replace(orpg.dirpath.dir_struct["user"]+'webfiles' + os.sep, open_rpg.get_component("cherrypy")) + '/' + filename | 93 min_url = dlg.GetDirectory().replace(orpg.dirpath.dir_struct["user"]+'webfiles' + os.sep, |
94 open_rpg.get_component("cherrypy")) + '/' + filename | |
100 | 95 |
101 if self.bg_type.GetStringSelection() == 'Texture': | 96 if self.bg_type.GetStringSelection() == 'Texture': |
102 self.canvas.layers['bg'].set_texture(min_url) | 97 self.canvas.layers['bg'].set_texture(min_url) |
103 elif self.bg_type.GetStringSelection() == 'Image': | 98 elif self.bg_type.GetStringSelection() == 'Image': |
104 self.size = self.canvas.layers['bg'].set_image(min_url,1) | 99 self.size = self.canvas.layers['bg'].set_image(min_url,1) |