Example #1
0
    def __init__(self, parent, id, object_id):

        # We know the id... why don't we not just fetch the object right away?
        self.object = objectCubeService.get_object_by_id(object_id)

        # Call the parent constructor.
        #wx.Dialog.__init__(self, parent, id, self.object.name, size=(400,500))
        wx.Dialog.__init__(self,
                           parent,
                           id,
                           self.object.name,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        # Center the window when we open it.
        self.CenterOnScreen()

        # Create frame for the image.
        self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400, 300))
        self.image_frame.SetBackgroundColour(wx.WHITE)

        bitmap = wx.Bitmap(self.object.name)
        bitmap = self.scale_bitmap(bitmap, 400, 300)
        control = wx.StaticBitmap(self.image_frame, -1, bitmap)
        #control.SetPosition((0, 0))

        # Read the image data into buffer.
        #buf = open(self.object.name, "rb").read()
        #self.image_buffer = StringIO.StringIO(buf)
        #self.raw_image = wx.ImageFromStream(self.image_buffer)

        #image = wx.ImageFromBitmap( self.raw_image.ConvertToBitmap() )
        #image = image.Scale(100, 100, wx.IMAGE_QUALITY_HIGH)
        #result = wx.BitmapFromImage(image)

        #bmp = self.raw_image.ConvertToBitmap()
        #DC = wx.PaintDC(self.image_frame)
        #DC.DrawBitmap(bmp, 0, 0)

        #print 'raw image', dir(self.raw_image)
        #print self.raw_image.GetData()

        # Create frame for the image.
        #self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400,300))
        #self.image_frame.SetBackgroundColour(wx.WHITE)

        #image_frame_menubar = wx.MenuBar()
        #file = wx.Menu()

        #file.Append(5000, 'Bigger', 'Quit application')

        #image_frame_menubar.Append(file, '&Size')
        #self.image_frame.SetMenuBar(image_frame_menubar)

        #self.image_frame.CenterOnScreen()
        self.image_frame.Show()

        # Create the object tags list.
        self.objectTagList = ObjectTagsList(self, self.object)

        # Create control buttons.
        self.btn_add_tag = wx.Button(self, id=-1, label='Add tag to object')
        self.btn_remove_selected_tag = wx.Button(self,
                                                 id=-1,
                                                 label='Remove selected tags')
        self.btn_remove_object = wx.Button(self,
                                           id=-1,
                                           label='Delete this object')

        # Bind events to the control buttons.
        self.Bind(wx.EVT_BUTTON, self.on_button_add_tagset, self.btn_add_tag)
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_selected_tag,
                  self.btn_remove_selected_tag)
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_object,
                  self.btn_remove_object)

        # Paing event
        #self.image_frame.Bind( wx.EVT_PAINT, self.OnPaint )
        #self.image_frame.Bind( wx.EVT_SIZE, self.OnResize )
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # Create horizontal box sizer for the buttons.
        self.button_box = wx.BoxSizer(wx.HORIZONTAL)
        self.button_box.Add(self.btn_add_tag, 1, wx.EXPAND)
        self.button_box.Add(self.btn_remove_selected_tag, 1, wx.EXPAND)
        self.button_box.Add(self.btn_remove_object, 1, wx.EXPAND)

        # Create sizer for this dialog.
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.objectTagList, 1, wx.EXPAND)
        self.sizer.Add(self.button_box, 0, wx.EXPAND)
        self.SetSizer(self.sizer)
Example #2
0
    def __init__(self, parent, id, object_id):
        
        # We know the id... why don't we not just fetch the object right away?
        self.object = objectCubeService.get_object_by_id(object_id) 

        # Call the parent constructor.
        #wx.Dialog.__init__(self, parent, id, self.object.name, size=(400,500))
        wx.Dialog.__init__(self, parent, id, self.object.name, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        # Center the window when we open it.
        self.CenterOnScreen()


        # Create frame for the image.
        self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400,300))
        self.image_frame.SetBackgroundColour(wx.WHITE)

        bitmap = wx.Bitmap(self.object.name)
        bitmap = self.scale_bitmap(bitmap, 400, 300)
        control = wx.StaticBitmap(self.image_frame, -1, bitmap)
        #control.SetPosition((0, 0))


        # Read the image data into buffer.    
        #buf = open(self.object.name, "rb").read()
        #self.image_buffer = StringIO.StringIO(buf)
        #self.raw_image = wx.ImageFromStream(self.image_buffer)
        
        #image = wx.ImageFromBitmap( self.raw_image.ConvertToBitmap() )
        #image = image.Scale(100, 100, wx.IMAGE_QUALITY_HIGH)
        #result = wx.BitmapFromImage(image)
        
        #bmp = self.raw_image.ConvertToBitmap()
        #DC = wx.PaintDC(self.image_frame)
        #DC.DrawBitmap(bmp, 0, 0)        
        
        
        
        
        
        #print 'raw image', dir(self.raw_image)
        #print self.raw_image.GetData()
        
        # Create frame for the image.
        #self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400,300))
        #self.image_frame.SetBackgroundColour(wx.WHITE)
        

        #image_frame_menubar = wx.MenuBar()
        #file = wx.Menu()
        
        #file.Append(5000, 'Bigger', 'Quit application')
        
        
        #image_frame_menubar.Append(file, '&Size')
        #self.image_frame.SetMenuBar(image_frame_menubar)

        #self.image_frame.CenterOnScreen()
        self.image_frame.Show()
        
        # Create the object tags list.
        self.objectTagList = ObjectTagsList(self, self.object)

        # Create control buttons.
        self.btn_add_tag = wx.Button(self, id=-1, label='Add tag to object') 
        self.btn_remove_selected_tag = wx.Button(self, id=-1, label='Remove selected tags')
        self.btn_remove_object = wx.Button(self, id=-1, label='Delete this object')
        
        # Bind events to the control buttons.
        self.Bind(wx.EVT_BUTTON, self.on_button_add_tagset, self.btn_add_tag) 
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_selected_tag, self.btn_remove_selected_tag)
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_object, self.btn_remove_object)
        
        # Paing event
        #self.image_frame.Bind( wx.EVT_PAINT, self.OnPaint )
        #self.image_frame.Bind( wx.EVT_SIZE, self.OnResize )
        self.Bind( wx.EVT_CLOSE, self.OnClose )
        
        
                
        # Create horizontal box sizer for the buttons.
        self.button_box = wx.BoxSizer(wx.HORIZONTAL)
        self.button_box.Add(self.btn_add_tag,1,wx.EXPAND)
        self.button_box.Add(self.btn_remove_selected_tag,1,wx.EXPAND)
        self.button_box.Add(self.btn_remove_object,1,wx.EXPAND)

        # Create sizer for this dialog.
        self.sizer=wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.objectTagList,1,wx.EXPAND)
        self.sizer.Add(self.button_box,0,wx.EXPAND) 
        self.SetSizer(self.sizer)
Example #3
0
class ViewObjectDialog(wx.Dialog):
    """
    Dialog for viewing tags that have been added to objects.
    """
    def scale_bitmap(self, bitmap, width, height):
        image = wx.ImageFromBitmap(bitmap)
        image = image.Scale(width, height, wx.IMAGE_QUALITY_HIGH)
        result = wx.BitmapFromImage(image)
        return result

    def __init__(self, parent, id, object_id):

        # We know the id... why don't we not just fetch the object right away?
        self.object = objectCubeService.get_object_by_id(object_id)

        # Call the parent constructor.
        #wx.Dialog.__init__(self, parent, id, self.object.name, size=(400,500))
        wx.Dialog.__init__(self,
                           parent,
                           id,
                           self.object.name,
                           style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        # Center the window when we open it.
        self.CenterOnScreen()

        # Create frame for the image.
        self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400, 300))
        self.image_frame.SetBackgroundColour(wx.WHITE)

        bitmap = wx.Bitmap(self.object.name)
        bitmap = self.scale_bitmap(bitmap, 400, 300)
        control = wx.StaticBitmap(self.image_frame, -1, bitmap)
        #control.SetPosition((0, 0))

        # Read the image data into buffer.
        #buf = open(self.object.name, "rb").read()
        #self.image_buffer = StringIO.StringIO(buf)
        #self.raw_image = wx.ImageFromStream(self.image_buffer)

        #image = wx.ImageFromBitmap( self.raw_image.ConvertToBitmap() )
        #image = image.Scale(100, 100, wx.IMAGE_QUALITY_HIGH)
        #result = wx.BitmapFromImage(image)

        #bmp = self.raw_image.ConvertToBitmap()
        #DC = wx.PaintDC(self.image_frame)
        #DC.DrawBitmap(bmp, 0, 0)

        #print 'raw image', dir(self.raw_image)
        #print self.raw_image.GetData()

        # Create frame for the image.
        #self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400,300))
        #self.image_frame.SetBackgroundColour(wx.WHITE)

        #image_frame_menubar = wx.MenuBar()
        #file = wx.Menu()

        #file.Append(5000, 'Bigger', 'Quit application')

        #image_frame_menubar.Append(file, '&Size')
        #self.image_frame.SetMenuBar(image_frame_menubar)

        #self.image_frame.CenterOnScreen()
        self.image_frame.Show()

        # Create the object tags list.
        self.objectTagList = ObjectTagsList(self, self.object)

        # Create control buttons.
        self.btn_add_tag = wx.Button(self, id=-1, label='Add tag to object')
        self.btn_remove_selected_tag = wx.Button(self,
                                                 id=-1,
                                                 label='Remove selected tags')
        self.btn_remove_object = wx.Button(self,
                                           id=-1,
                                           label='Delete this object')

        # Bind events to the control buttons.
        self.Bind(wx.EVT_BUTTON, self.on_button_add_tagset, self.btn_add_tag)
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_selected_tag,
                  self.btn_remove_selected_tag)
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_object,
                  self.btn_remove_object)

        # Paing event
        #self.image_frame.Bind( wx.EVT_PAINT, self.OnPaint )
        #self.image_frame.Bind( wx.EVT_SIZE, self.OnResize )
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # Create horizontal box sizer for the buttons.
        self.button_box = wx.BoxSizer(wx.HORIZONTAL)
        self.button_box.Add(self.btn_add_tag, 1, wx.EXPAND)
        self.button_box.Add(self.btn_remove_selected_tag, 1, wx.EXPAND)
        self.button_box.Add(self.btn_remove_object, 1, wx.EXPAND)

        # Create sizer for this dialog.
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.objectTagList, 1, wx.EXPAND)
        self.sizer.Add(self.button_box, 0, wx.EXPAND)
        self.SetSizer(self.sizer)

    def OnClose(self, ev):
        try:
            self.image_frame.Close()
        except:
            print 'image was dead.'
        ev.Skip()

    def OnPaint(self, Event):
        print 'nice'
        #raw_image = wx.Image(self.image_buffer)
        #raw_image = wx.ImageFromStream(self.image_buffer)
        #print self.image_buffer
        #raw_image.Rescale(self.image_frame.GetSize()[0], self.image_frame.GetSize()[1]);
        #bmp = self.raw_image.ConvertToBitmap()
        #DC = wx.PaintDC(self.image_frame)
        #DC.DrawBitmap(bmp, 0, 0)
        #Event.Skip()
        pass

    def OnResize(self, Event):
        print 'resize event'
        #buf = open(self.object.name, "rb").read()
        #self.image_buffer = StringIO.StringIO(buf)
        #self.raw_image = wx.ImageFromStream(self.image_buffer)
        #self.raw_image.Rescale(self.image_frame.GetSize()[0], self.image_frame.GetSize()[1]);
        #Event.Skip()

    def on_button_add_tagset(self, event):
        dlg = AddTagToObjectDialog(self, self.object.id)
        result = dlg.ShowModal()
        if result == wx.ID_OK:
            self.objectTagList.reload_data()

    def on_button_remove_selected_tag(self, event):
        if self.objectTagList.has_selected():
            dlg = wx.MessageDialog(
                self, 'Are you sure you want to remove tag from object?',
                'Remove tag from object?', wx.YES | wx.NO | wx.ICON_ERROR)
            result = dlg.ShowModal()
            if result == wx.ID_YES:
                self.objectTagList.remove_selected()
        else:
            wx.MessageBox('Please select tags to remove.', 'Info')

    def on_button_remove_object(self, event):
        """
        Event function. This function is called when remove object button is
        clicked. Opens up MessageDialog and removes object if user presses yes.
        """
        dlg = wx.MessageDialog(self,
                               'Are you sure you want to delete this object?',
                               'Delete object?',
                               wx.NO | wx.YES | wx.ICON_ERROR)
        result = dlg.ShowModal()
        if result == wx.ID_YES:
            self.Destroy()
Example #4
0
class ViewObjectDialog(wx.Dialog):
    """
    Dialog for viewing tags that have been added to objects.
    """
    
    
    def scale_bitmap(self, bitmap, width, height):
        image = wx.ImageFromBitmap(bitmap)
        image = image.Scale(width, height, wx.IMAGE_QUALITY_HIGH)
        result = wx.BitmapFromImage(image)
        return result
    

    def __init__(self, parent, id, object_id):
        
        # We know the id... why don't we not just fetch the object right away?
        self.object = objectCubeService.get_object_by_id(object_id) 

        # Call the parent constructor.
        #wx.Dialog.__init__(self, parent, id, self.object.name, size=(400,500))
        wx.Dialog.__init__(self, parent, id, self.object.name, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        # Center the window when we open it.
        self.CenterOnScreen()


        # Create frame for the image.
        self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400,300))
        self.image_frame.SetBackgroundColour(wx.WHITE)

        bitmap = wx.Bitmap(self.object.name)
        bitmap = self.scale_bitmap(bitmap, 400, 300)
        control = wx.StaticBitmap(self.image_frame, -1, bitmap)
        #control.SetPosition((0, 0))


        # Read the image data into buffer.    
        #buf = open(self.object.name, "rb").read()
        #self.image_buffer = StringIO.StringIO(buf)
        #self.raw_image = wx.ImageFromStream(self.image_buffer)
        
        #image = wx.ImageFromBitmap( self.raw_image.ConvertToBitmap() )
        #image = image.Scale(100, 100, wx.IMAGE_QUALITY_HIGH)
        #result = wx.BitmapFromImage(image)
        
        #bmp = self.raw_image.ConvertToBitmap()
        #DC = wx.PaintDC(self.image_frame)
        #DC.DrawBitmap(bmp, 0, 0)        
        
        
        
        
        
        #print 'raw image', dir(self.raw_image)
        #print self.raw_image.GetData()
        
        # Create frame for the image.
        #self.image_frame = wx.Frame(None, -1, "Test Frame", size=(400,300))
        #self.image_frame.SetBackgroundColour(wx.WHITE)
        

        #image_frame_menubar = wx.MenuBar()
        #file = wx.Menu()
        
        #file.Append(5000, 'Bigger', 'Quit application')
        
        
        #image_frame_menubar.Append(file, '&Size')
        #self.image_frame.SetMenuBar(image_frame_menubar)

        #self.image_frame.CenterOnScreen()
        self.image_frame.Show()
        
        # Create the object tags list.
        self.objectTagList = ObjectTagsList(self, self.object)

        # Create control buttons.
        self.btn_add_tag = wx.Button(self, id=-1, label='Add tag to object') 
        self.btn_remove_selected_tag = wx.Button(self, id=-1, label='Remove selected tags')
        self.btn_remove_object = wx.Button(self, id=-1, label='Delete this object')
        
        # Bind events to the control buttons.
        self.Bind(wx.EVT_BUTTON, self.on_button_add_tagset, self.btn_add_tag) 
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_selected_tag, self.btn_remove_selected_tag)
        self.Bind(wx.EVT_BUTTON, self.on_button_remove_object, self.btn_remove_object)
        
        # Paing event
        #self.image_frame.Bind( wx.EVT_PAINT, self.OnPaint )
        #self.image_frame.Bind( wx.EVT_SIZE, self.OnResize )
        self.Bind( wx.EVT_CLOSE, self.OnClose )
        
        
                
        # Create horizontal box sizer for the buttons.
        self.button_box = wx.BoxSizer(wx.HORIZONTAL)
        self.button_box.Add(self.btn_add_tag,1,wx.EXPAND)
        self.button_box.Add(self.btn_remove_selected_tag,1,wx.EXPAND)
        self.button_box.Add(self.btn_remove_object,1,wx.EXPAND)

        # Create sizer for this dialog.
        self.sizer=wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.objectTagList,1,wx.EXPAND)
        self.sizer.Add(self.button_box,0,wx.EXPAND) 
        self.SetSizer(self.sizer)
    
    
    
    
    
    
    
    
    def OnClose(self, ev):
        try:
            self.image_frame.Close()
        except:
            print 'image was dead.'
        ev.Skip()
    
    
    
    def OnPaint(self, Event):
        print 'nice'
        #raw_image = wx.Image(self.image_buffer)
        #raw_image = wx.ImageFromStream(self.image_buffer)
        #print self.image_buffer
        #raw_image.Rescale(self.image_frame.GetSize()[0], self.image_frame.GetSize()[1]);
        #bmp = self.raw_image.ConvertToBitmap()
        #DC = wx.PaintDC(self.image_frame)
        #DC.DrawBitmap(bmp, 0, 0)
        #Event.Skip()
        pass
    
    def OnResize(self, Event):
        print 'resize event'
        #buf = open(self.object.name, "rb").read()
        #self.image_buffer = StringIO.StringIO(buf)
        #self.raw_image = wx.ImageFromStream(self.image_buffer)
        #self.raw_image.Rescale(self.image_frame.GetSize()[0], self.image_frame.GetSize()[1]);
        #Event.Skip()        
    
    
    
    def on_button_add_tagset(self, event):
        dlg = AddTagToObjectDialog(self, self.object.id)
        result = dlg.ShowModal()
        if result == wx.ID_OK:
            self.objectTagList.reload_data()

    
    def on_button_remove_selected_tag(self, event):
        if self.objectTagList.has_selected():
            dlg = wx.MessageDialog(self, 'Are you sure you want to remove tag from object?', 'Remove tag from object?', wx.YES | wx.NO | wx.ICON_ERROR)
            result = dlg.ShowModal()
            if result == wx.ID_YES:
                self.objectTagList.remove_selected()
        else:
            wx.MessageBox('Please select tags to remove.', 'Info')

    def on_button_remove_object(self, event):
        """
        Event function. This function is called when remove object button is
        clicked. Opens up MessageDialog and removes object if user presses yes.
        """
        dlg = wx.MessageDialog(self, 'Are you sure you want to delete this object?', 'Delete object?', wx.NO | wx.YES | wx.ICON_ERROR)
        result = dlg.ShowModal()
        if result == wx.ID_YES:
            self.Destroy()