from wx import TextCtrl, StaticText, ALIGN_CENTER, RadioButton, BoxSizer, HORIZONTAL, VERTICAL, StaticLine, EXPAND, ALL, BOTTOM, LEFT, RIGHT, Point
import wx
from util import Storage as S, callsback, traceguard
from traceback import print_exc
from cgui import getScreenBitmap, GetTrayRect
from gui import skin
from gui.toolbox import Monitor
from PIL import Image, ImageDraw
from cStringIO import StringIO
from gui.imagedialog import ImageDialog
import wx.lib.sized_controls as sc
SCREENSHOT_TIMER_SECS = 4
class BugReportPanel(sc.SizedPanel):
def __init__(self, parent, callback = None):
sc.SizedPanel.__init__(self, parent)
self.screenshot = None
self.construct()
self.callback = callback
if callback is not None:
self.Bind(wx.EVT_BUTTON, self.OnButton)
def OnButton(self, e):
e.Skip()
b = e.EventObject
if b is self.submit:
pass
submit = self.callback is not None
if submit and not (self.input.Value):
e.Skip(False)
wx.MessageBox(_('Please enter a description of the bug.\n\nInclude as much information as possible about\nwhat went wrong and how to reproduce the issue.'), _('Send Bug Report'))
return None
def after():
try:
if submit:
self.callback(self.info())
finally:
self.Destroy()
wx.CallAfter(after)
def construct(self):
Text = lambda *a, **k: StaticText(self, -1, *a, **k)
def BoldText(*a, **k):
t = Text(*a, **k)
t.SetBold()
return t
self.header = BoldText(_('Use this tool to submit a diagnostic log right after you experience a bug'), style = ALIGN_CENTER)
self.subheader = Text(_('This diagnostic log file does not contain personal data such as the content of sent/received IMs,the content of emails, and the content of social network newsfeeds except where it directly pertains to an error.'), style = ALIGN_CENTER | wx.ST_NO_AUTORESIZE)
self.subheader.SetSizerProps(expand = True)
self.line = StaticLine(self)
self.input_desc = BoldText(_('Please describe the bug in as much detail as possible. Include information such as\nwhat you were doing when the bug occurred and exactly what goes wrong.'))
self.subheader.SetLabel(_('This diagnostic log file does not contain personal data such as the content of sent/received IMs, the content of emails, and the content of social network newsfeeds except where it directly pertains to an error.'))
self.subheader.Wrap(event.Size.width)
self.input_desc.SetLabel(_('Please describe the bug in as much detail as possible. Include information such as what you were doing when the bug occured and exactly what goes wrong.'))
self.input_desc.Wrap(event.Size.width)
event.Skip()
def OnScreenshot(self, e):
if self.screenshot_timer.IsRunning() or self.screenshot is not None:
diag = ImageDialog(self, screen, pos = oldpos + Point(40, 40), title = _('Submit Bug Report - Screenshot - Digsby'), message = _('Is it OK to send this screenshot to digsby.com?'))