from wx import TextCtrl, StaticText, ALIGN_CENTER, RadioButton, BoxSizer, HORIZONTAL, VERTICAL, StaticLine, EXPAND, Button, ALL, TOP, BOTTOM, LEFT, RIGHT, Point
import wx
from util import Storage as S, callsback, traceguard
from traceback import print_exc
from gui.toolbox.imagefx import pil_to_wxb_nocache
from cgui import getScreenBitmap, GetTrayRect
from gui import skin
from gui.toolbox import Monitor
from PIL import Image, ImageDraw
from PIL.Image import BICUBIC, ANTIALIAS
from cStringIO import StringIO
from logging import getLogger
log = getLogger('bugreporter')
from gui.imagedialog import ImageDialog
import wx.lib.sized_controls as sc
SCREENSHOT_TIMER_SECS = 4
num_screenshots = 0
class BugReportPanel(sc.SizedPanel):
def __init__(self, parent, callback = None):
sc.SizedPanel.__init__(self, parent)
self.screenshot = None
self.construct()
self.callback = callback
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,\nthe content of emails, and the content of social network newsfeeds except where it directly pertains to an error.'), style = ALIGN_CENTER)
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 OnScreenshotLinkTimer(self, l):
if wx.IsDestroyed(self):
self.screenshot_timer.Stop()
return None
self.SetScreenshotLabel(l)
def SetScreenshotLabel(self, l):
self.screenshot_link.SetLabel(l)
self.Layout()
self.screenshot_link.Refresh()
def OnScreenshot(self, e):
if self.screenshot_timer.IsRunning() or self.screenshot is not None:
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
try:
if submit:
self.callback(self.panel.info())
finally:
self.Destroy()
def resize_screenshot(img):
(w, h) = img.size
squaresize = 650
if w > h:
new_height = int((h / float(w)) * squaresize)
img = None(img.resize, (squaresize, new_height) if squaresize > w else ANTIALIAS)
else:
new_width = int((w / float(h)) * squaresize)
img = None(img.resize, (new_width, squaresize) if squaresize > h else ANTIALIAS)