Example #1
0
 def goto(self, number=None):
     """ Ask event number in dialog and navigate and to event.
     """
     logging.debug(__name__ + ": goto")
     if self._dataAccessor.numberOfEvents():
         max = self._dataAccessor.numberOfEvents()
     else:
         max = sys.maxsize
     if number != None:
         ok = (number >= 1, number <= max)
     else:
         if hasattr(QInputDialog, "getInteger"):
             # Qt 4.3
             (number, ok) = QInputDialog.getInteger(
                 self.plugin().application().mainWindow(),
                 "Goto...", "Enter event number:",
                 self._dataAccessor.eventNumber(), 1, max)
         else:
             # Qt 4.5
             (number, ok) = QInputDialog.getInt(
                 self.plugin().application().mainWindow(),
                 "Goto...", "Enter event number:",
                 self._dataAccessor.eventNumber(), 1, max)
     if ok:
         self.cancel()
         currentEvent = self.dataAccessor().eventNumber()
         if currentEvent != number:
             self.navigate(number)
Example #2
0
	def penWidth(self):
		# opens dialog to change pen width
		newWidth, ok = QInputDialog.getInteger(self.parent, "Pen width",
			"Select pen width:",
			self.scribbleArea.penWidth(), 1, 50, 1)
		if ok:
			self.scribbleArea.setPenWidth(newWidth)
Example #3
0
 def change_history_depth(self):
     "Change history max entries" ""
     depth, valid = QInputDialog.getInteger(
         self, self.tr('History'), self.tr('Maximum entries'),
         CONF.get(self.ID, 'max_entries'), 10, 10000)
     if valid:
         CONF.set(self.ID, 'max_entries', depth)
Example #4
0
 def make_jss(self, html):
     ' make js '
     indnt = ' ' * int(QInputDialog.getInteger(None, __doc__,
                       " JS Indentation Spaces: ", 4, 0, 8, 2)[0])
     scrpt = QInputDialog.getItem(None, __doc__, "Enclosing script Tags ?",
                     ['Use script html tags', 'No script tags'], 0, False)[0]
     p = True if 'Use script html tags' in scrpt else False
     self.soup = self.get_soup(html)
     jss = '<script>{}'.format(linesep) if p is True else ''
     jss += '//{} by {}{}'.format(datetime.now().isoformat().split('.')[0],
                                    getuser(), linesep)
     jss += '$(document).ready(function(){' + linesep
     previously_styled = []
     previously_styled.append(tag_2_ignore)
     jss += '{}//{}{}'.format(linesep, '-' * 76, linesep)
     for part in self.get_ids():
         if part not in previously_styled:
             jss += '{}//{}{}'.format(indnt, '#'.join(part).lower(), linesep)
             jss += js_template.format(indnt, 'var ',
                    re.sub('[^a-z]', '', part[1].lower() if len(part[1]) < 11 else re.sub('[aeiou]', '', part[1].lower())),
                    ' = ', '$("#{}").lenght'.format(part[1]), ';', linesep,
                    linesep, '')
             previously_styled.append(part)
     jss += '//{}{}'.format('-' * 76, linesep)
     for part in self.get_classes():
         if part not in previously_styled:
             jss += '{}//{}{}'.format(indnt, '.'.join(part).lower(), linesep)
             jss += js_template.format(indnt, 'var ',
                    re.sub('[^a-z]', '', part[1].lower() if len(part[1]) < 11 else re.sub('[aeiou]', '', part[1].lower())),
                    ' = ', '$(".{}").lenght'.format(part[1]), ';', linesep,
                    linesep, '')
             previously_styled.append(part)
     jss += '});'
     jss += '{}</script>'.format(linesep) if p is True else ''
     return jss.strip()
 def editZoom(self):
     if self.image.isNull():
         return
     percent, ok = QInputDialog.getInteger(self,
             "Image Changer - Zoom", "Percent:",
             self.zoomSpinBox.value(), 1, 400)
     if ok:
         self.zoomSpinBox.setValue(percent)
Example #6
0
 def change_history_depth(self):
     "Change history max entries"""
     depth, valid = QInputDialog.getInteger(self, _('History'),
                                    _('Maximum entries'),
                                    self.get_option('max_entries'),
                                    10, 10000)
     if valid:
         self.set_option('max_entries', depth)
Example #7
0
 def change_max_line_count(self):
     "Change maximum line count" ""
     mlc, valid = QInputDialog.getInteger(
         self, _("Buffer"), _("Maximum line count"), self.get_option("max_line_count"), 0, 1000000
     )
     if valid:
         self.shell.setMaximumBlockCount(mlc)
         self.set_option("max_line_count", mlc)
Example #8
0
 def change_history_depth(self):
     "Change history max entries"""
     depth, valid = QInputDialog.getInteger(self, self.tr('History'),
                                    self.tr('Maximum entries'),
                                    CONF.get(self.ID, 'max_entries'),
                                    10, 10000)
     if valid:
         CONF.set(self.ID, 'max_entries', depth)
Example #9
0
 def editZoom(self):
     if self.image.isNull():
         return
     percent, ok = QInputDialog.getInteger(self, "Image Changer - Zoom",
                                           "Percent:",
                                           self.zoomSpinBox.value(), 1, 400)
     if ok:
         self.zoomSpinBox.setValue(percent)
Example #10
0
 def change_max_line_count(self):
     "Change maximum line count"""
     mlc, valid = QInputDialog.getInteger(self, self.tr('Buffer'),
                                        self.tr('Maximum line count'),
                                        CONF.get(self.ID, 'max_line_count'),
                                        10, 1000000)
     if valid:
         self.shell.setMaximumBlockCount(mlc)
         CONF.set(self.ID, 'max_line_count', mlc)
Example #11
0
 def goToLine(self):
     maxLine = str(self.textEdit.lines())
     newLineNumber, ok = QInputDialog.getInteger(self.centralwidget,
                                                 "Go to line",
                                                 "Line number: (1, " + maxLine+")")
     if ok:
         newLineNumber -= 1  # Convert from 1-based to 0-based
         self.textEdit.ensureLineVisible(newLineNumber)
         self.textEdit.setCursorPosition(newLineNumber, 0)
Example #12
0
 def zoomDialog(self):
     if hasattr(QInputDialog, "getInteger"):
         # Qt 4.3
         (zoom, ok) = QInputDialog.getInteger(self.tab(), "Zoom...", "Input zoom factor in percent:", self.zoom(), 0)
     else:
         # Qt 4.5
         (zoom, ok) = QInputDialog.getInt(self.tab(), "Zoom...", "Input zoom factor in percent:", self.zoom(), 0)
     if ok:
         self.setZoom(zoom)
         self._userZoomLevel = zoom
Example #13
0
 def invokeGoTo(self):
     """Show GUI dialog, go to line, if user accepted it
     """
     line = self.cursorPosition()[0]
     gotoLine, accepted = QInputDialog.getInteger(self, self.tr( "Go To Line..." ),
                                                   self.tr( "Enter the line you want to go:" ), 
                                                   line, 1, self.lineCount(), 1)
     gotoLine -= 1
     if accepted:
         self.goTo(line = gotoLine, grabFocus = True)
Example #14
0
File: document.py Project: vi/enki
 def invokeGoTo(self):
     """Show GUI dialog, go to line, if user accepted it
     """
     line = self.qutepart.cursorPosition[0]
     gotoLine, accepted = QInputDialog.getInteger(self, self.tr( "Go To Line..." ),
                                                   self.tr( "Enter the line you want to go:" ),
                                                   line, 1, len(self.qutepart.lines), 1)
     if accepted:
         gotoLine -= 1
         self.qutepart.cursorPosition = gotoLine, None
         self.setFocus()
Example #15
0
 def invokeGoTo(self):
     """Show GUI dialog, go to line, if user accepted it
     """
     line = self.qutepart.cursorPosition[0]
     gotoLine, accepted = QInputDialog.getInteger(
         self, self.tr("Go To Line..."),
         self.tr("Enter the line you want to go:"), line, 1,
         len(self.qutepart.lines), 1)
     if accepted:
         gotoLine -= 1
         self.qutepart.cursorPosition = gotoLine, None
         self.setFocus()
 def expandToDepthDialog(self):
     """ Show dialog and expand center view to depth.
     """
     if hasattr(QInputDialog, "getInteger"):
         # Qt 4.3
         (depth, ok) = QInputDialog.getInteger(self.tab(), "Expand to depth...", "Input depth:", self._treeDepth, 0)
     else:
         # Qt 4.5
         (depth, ok) = QInputDialog.getInt(self.tab(), "Expand to depth...", "Input depth:", self._treeDepth, 0)
     if ok:
         self._treeDepth=depth
         if self.tab().treeView().selection():
             self.onTreeViewSelected(self.tab().treeView().selection())
Example #17
0
	def onReloadTime(self):
		ok = False
		value, ok = QInputDialog.getInteger(self,
			self.tr("reloadinterval"), # title
			self.tr("insert time in s"), # text
			self.config.loadReloadInterval(), # default
			10, # minimum
			86400, # maximum (at least once a day)
			1, # step
			)
		if ok:
			self.config.saveReloadInterval(value)
			self.pBar.setRange(0,self.config.loadReloadInterval())
			self.reload_()
Example #18
0
 def expandToDepthDialog(self):
     """ Show dialog and call expandToDepth() function of tree view.
     """
     if hasattr(QInputDialog, "getInteger"):
         # Qt 4.3
         (depth, ok) = QInputDialog.getInteger(self, "Expand to depth...", "Input depth:", self._treeDepth, 0)
     else:
         # Qt 4.5
         (depth, ok) = QInputDialog.getInt(self, "Expand to depth...", "Input depth:", self._treeDepth, 0)
     if ok:
         self._treeDepth=depth
         self.collapseAll(False)
         if self._treeDepth>0:
             self.expandToDepth(self._treeDepth-1)
Example #19
0
 def zoomDialog(self):
     if hasattr(QInputDialog, "getInteger"):
         # Qt 4.3
         (zoom,
          ok) = QInputDialog.getInteger(self.tab(), "Zoom...",
                                        "Input zoom factor in percent:",
                                        self.zoom(), 0)
     else:
         # Qt 4.5
         (zoom, ok) = QInputDialog.getInt(self.tab(), "Zoom...",
                                          "Input zoom factor in percent:",
                                          self.zoom(), 0)
     if ok:
         self.setZoom(zoom)
         self._userZoomLevel = zoom
Example #20
0
 def expandToDepthDialog(self):
     """ Show dialog and expand center view to depth.
     """
     if hasattr(QInputDialog, "getInteger"):
         # Qt 4.3
         (depth,
          ok) = QInputDialog.getInteger(self.tab(), "Expand to depth...",
                                        "Input depth:", self._treeDepth, 0)
     else:
         # Qt 4.5
         (depth, ok) = QInputDialog.getInt(self.tab(), "Expand to depth...",
                                           "Input depth:", self._treeDepth,
                                           0)
     if ok:
         self._treeDepth = depth
         if self.tab().treeView().selection():
             self.onTreeViewSelected(self.tab().treeView().selection())
Example #21
0
 def expandToDepthDialog(self):
     """ Show dialog and call expandToDepth() function of tree view.
     """
     if hasattr(QInputDialog, "getInteger"):
         # Qt 4.3
         (depth, ok) = QInputDialog.getInteger(self, "Expand to depth...",
                                               "Input depth:",
                                               self._treeDepth, 0)
     else:
         # Qt 4.5
         (depth, ok) = QInputDialog.getInt(self, "Expand to depth...",
                                           "Input depth:", self._treeDepth,
                                           0)
     if ok:
         self._treeDepth = depth
         self.collapseAll(False)
         if self._treeDepth > 0:
             self.expandToDepth(self._treeDepth - 1)
Example #22
0
 def make_css(self, html):
     ' make css '
     indnt = ' ' * int(
         QInputDialog.getInteger(None, __doc__, " CSS Indentation Spaces: ",
                                 4, 0, 8, 2)[0])
     plchs = QInputDialog.getItem(None, __doc__, "CSS Placeholder values?",
                                  ['Blank Empty CSS', 'Placeholders'], 0,
                                  False)[0]
     p = True if 'Placeholders' in plchs else False
     self.soup = self.get_soup(html)
     css, previously_styled = '@charset "utf-8";', []
     css += '/*{} by {}*/{}'.format(
         datetime.now().isoformat().split('.')[0], getuser(), linesep * 2)
     previously_styled.append(css_2_ignore)
     for part in self.get_tags():
         if part not in previously_styled:
             css += '{}{}{}{}{}{}{}'.format(
                 part, '{', linesep, indnt,
                 choice(placeholders) + linesep if p is True else linesep,
                 '}', linesep)
             previously_styled.append(part)
     css += '/*{}*/{}'.format('-' * 76, linesep)
     for part in self.get_ids():
         if part not in previously_styled:
             css += '/* {} */{}'.format('_'.join(part).lower(), linesep)
             css += css_template.format(
                 '', '#', part[1], '{', linesep, indnt,
                 choice(placeholders) + linesep if p is True else linesep,
                 '}', linesep)
             previously_styled.append(part)
     css += '/*{}*/{}'.format('-' * 76, linesep)
     for part in self.get_classes():
         if part not in previously_styled:
             css += '/* {} */{}'.format('_'.join(part).lower(), linesep)
             css += css_template.format(
                 '', '.', ',.'.join(part[1].split(' ')), '{', linesep,
                 indnt,
                 choice(placeholders) + linesep if p is True else linesep,
                 '}', linesep)
             previously_styled.append(part)
     return css.strip()
 def goto(self, number=None):
     """ Ask event number in dialog and navigate and to event.
     """
     logging.debug(__name__ + ": goto")
     if self._dataAccessor.numberOfEvents():
         max = self._dataAccessor.numberOfEvents()
     else:
         max = sys.maxsize
     if number!=None:
         ok=(number>=1, number<=max)
     else:
         if hasattr(QInputDialog, "getInteger"):
             # Qt 4.3
             (number, ok) = QInputDialog.getInteger(self.plugin().application().mainWindow(), "Goto...", "Enter event number:", self._dataAccessor.eventNumber(), 1, max)
         else:
             # Qt 4.5
             (number, ok) = QInputDialog.getInt(self.plugin().application().mainWindow(), "Goto...", "Enter event number:", self._dataAccessor.eventNumber(), 1, max)
     if ok:
         self.cancel()
         currentEvent=self.dataAccessor().eventNumber()
         if currentEvent!=number:
             self.navigate(number)
Example #24
0
 def make_css(self, html):
     ' make css '
     indnt = ' ' * int(QInputDialog.getInteger(None, __doc__,
                       " CSS Indentation Spaces: ", 4, 0, 8, 2)[0])
     plchs = QInputDialog.getItem(None, __doc__, "CSS Placeholder values?",
                            ['Blank Empty CSS', 'Placeholders'], 0, False)[0]
     p = True if 'Placeholders' in plchs else False
     self.soup = self.get_soup(html)
     css, previously_styled = '@charset "utf-8";', []
     css += '/*{} by {}*/{}'.format(datetime.now().isoformat().split('.')[0],
                                    getuser(), linesep * 2)
     previously_styled.append(css_2_ignore)
     for part in self.get_tags():
         if part not in previously_styled:
             css += '{}{}{}{}{}{}{}'.format(part, '{', linesep, indnt,
                    choice(placeholders) + linesep if p is True else linesep,
                    '}', linesep)
             previously_styled.append(part)
     css += '/*{}*/{}'.format('-' * 76, linesep)
     for part in self.get_ids():
         if part not in previously_styled:
             css += '/* {} */{}'.format('_'.join(part).lower(), linesep)
             css += css_template.format('', '#', part[1], '{', linesep,
                    indnt,
                    choice(placeholders) + linesep if p is True else linesep,
                    '}', linesep)
             previously_styled.append(part)
     css += '/*{}*/{}'.format('-' * 76, linesep)
     for part in self.get_classes():
         if part not in previously_styled:
             css += '/* {} */{}'.format('_'.join(part).lower(), linesep)
             css += css_template.format('', '.',
                    ',.'.join(part[1].split(' ')), '{', linesep, indnt,
                    choice(placeholders) + linesep if p is True else linesep,
                    '}', linesep)
             previously_styled.append(part)
     return css.strip()
Example #25
0
 def initialize(self, *args, **kwargs):
     " Init Main Class "
     super(Main, self).initialize(*args, **kwargs)
     self.locator.get_service("menuApp").add_action(QAction(QIcon.fromTheme("edit-select-all"), "XML to JSON", self, triggered=lambda: self.locator.get_service("editor").add_editor(content=dumps(parse(open(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open a XML File".format(__doc__), path.expanduser("~"), 'XML(*.xml)'))).read()), indent=int(QInputDialog.getInteger(None, __doc__, "JSON Indentation Spaces:", 4, 0, 8, 2)[0]), sort_keys=True), syntax='python')))
     self.locator.get_service("menuApp").add_action(QAction(QIcon.fromTheme("edit-select-all"), "JSON to XML", self, triggered=lambda: self.locator.get_service("editor").add_editor(content=parseString(dicttoxml(loads(open(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open a JSON File".format(__doc__), path.expanduser("~"), 'JSON(*.json)'))).read()))).toprettyxml(), syntax='python')))
 def templatag(self, action):
     ' parse and generate template markup '
     # QMessageBox.information(None, __doc__, action)
     if action in 'autoescape':
         self.locator.get_service("editor").insert_text('{% autoescape on %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endautoescape %}')
     elif action in 'block':
         self.locator.get_service("editor").insert_text('{% block ' + str(QInputDialog.getText(None, __doc__, "Type Block Name:", text='block_name')[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endblock %}')
     elif action in 'comment':
         self.locator.get_service("editor").insert_text('{% comment %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endcomment %}')
     elif action in 'csrf_token':
         self.locator.get_service("editor").insert_text('{% csrf_token %}')
     elif action in 'cycle':
         self.locator.get_service("editor").insert_text('{% cycle ' + str(QInputDialog.getText(None, __doc__, "Items to Cycle, Space separated:", text='item1 item2 item3')[0]).strip() + ' %} ')
     elif action in 'debug':
         self.locator.get_service("editor").insert_text('{% debug %}')
     elif action in 'extends':
         self.locator.get_service("editor").insert_text('{% extends "' + str(QInputDialog.getText(None, __doc__, "Parent Template to Extend:", text='base.html')[0]).strip() + '" %} ')
     elif action in 'extendsfile':
         self.locator.get_service("editor").insert_text('{% extends "' + str(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open File".format(__doc__), path.expanduser("~"), '*.*(*.*)'))).strip() + '" %} ')
     elif action in 'filter':
         self.locator.get_service("editor").insert_text('{% filter ' + str(QInputDialog.getText(None, __doc__, "Multiple filters with arguments, pipes separated:", text='lower|safe')[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endfilter %}')
     elif action in 'firstof':
         self.locator.get_service("editor").insert_text('{% filter force_escape %}{% firstof ' + str(QInputDialog.getText(None, __doc__, "Multiple variables, space separated:", text='var1 var2')[0]).strip() + ' "' + str(QInputDialog.getText(None, __doc__, "Literal string Fallback Value:", text='fallback_value')[0]).strip() + '" %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endfilter %}')
     elif action in 'for':
         self.locator.get_service("editor").insert_text('{% for ' + str(QInputDialog.getText(None, __doc__, "Variable to use to Iterate:", text='item')[0]).strip() + ' in ' + str(QInputDialog.getText(None, __doc__, "Sequence to Iterate:", text='values')[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endfor %}')
     elif action in 'for...empty':
         self.locator.get_service("editor").insert_text('{% if ' + str(QInputDialog.getText(None, __doc__, "String to check:", text='"foo"')[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% empty %} ' + str(QInputDialog.getText(None, __doc__, "Output to use if for loop is Empty:", text='"Nothing."')[0]).strip() + ' {% endfor %}')
     #elif action in 'if':
         #pass
     #elif action in '== operator':
         #pass
     #elif action in '!= operator':
         #pass
     #elif action in '< operator':
         #pass
     #elif action in '> operator':
         #pass
     #elif action in '<= operator':
         #pass
     #elif action in '>= operator':
         #pass
     elif action in 'in operator':
         self.locator.get_service("editor").insert_text('{% if ' + '{} in {}'.format(str(QInputDialog.getText(None, __doc__, "String to check:", text='"foo"')[0]).strip(), str(QInputDialog.getText(None, __doc__, "Variable to check into:", text='bar')[0]).strip()) + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endif %}')
     elif action in 'not in operator':
         self.locator.get_service("editor").insert_text('{% if ' + '{} not in {}'.format(str(QInputDialog.getText(None, __doc__, "String to check:", text='"foo"')[0]).strip(), str(QInputDialog.getText(None, __doc__, "Variable to check into:", text='bar')[0]).strip()) + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endif %}')
     elif action in 'ifchanged':
         self.locator.get_service("editor").insert_text('{% ifchanged ' + str(QInputDialog.getText(None, __doc__, "None, One or Multiple Variables to check if they changed, space separated:")[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endifchanged %}')
     elif action in 'ifequal':
         self.locator.get_service("editor").insert_text('{% ifequal ' + str(QInputDialog.getText(None, __doc__, "2 Variables or Strings to compare if equal, space separated:", text='"foo" "foo"')[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endifequal %}')
     elif action in 'ifnotequal':
         self.locator.get_service("editor").insert_text('{% ifnotequal ' + str(QInputDialog.getText(None, __doc__, "2 Variables or Strings to compare if Not equal, space separated:", text='"foo" "bar"')[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endifnotequal %}')
     elif action in 'include':
         self.locator.get_service("editor").insert_text('{% include "' + str(QInputDialog.getText(None, __doc__, "Parent Template to Include:", text='footer.html')[0]).strip() + '" %} ')
     elif action in 'includefile':
         self.locator.get_service("editor").insert_text('{% include "' + str(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open File".format(__doc__), path.expanduser("~"), '*.*(*.*)'))).strip() + '" %} ')
     elif action in 'load':
         self.locator.get_service("editor").insert_text('{% load ' + str(QInputDialog.getText(None, __doc__, "Template Tag to Load:", text='foo bar')[0]).strip() + ' %} ')
     elif action in 'now':
         self.locator.get_service("editor").insert_text('{% now "' + str(QInputDialog.getItem(None, __doc__, "Current Date Time format:", ['DATETIME_FORMAT', 'SHORT_DATETIME_FORMAT', 'SHORT_DATE_FORMAT', 'DATE_FORMAT'], 0, False)[0]) + '" %} ')
     elif action in 'regroup':
         self.locator.get_service("editor").insert_text('{% regroup ' + str(QInputDialog.getText(None, __doc__, "Regroup a list of alike objects by a common attribute:", text='cities by country as country_list')[0]).strip() + ' %} ')
     elif action in 'spaceless':
         self.locator.get_service("editor").insert_text('{% spaceless %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endspaceless %}')
     elif action in 'ssi':
         self.locator.get_service("editor").insert_text('{% ssi "' + str(QInputDialog.getText(None, __doc__, "Full Path to Template to Include:", text='/tmp/template.html')[0]).strip() + '" parsed %} ')
     elif action in 'ssifile':
         self.locator.get_service("editor").insert_text('{% ssi "' + str(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open File".format(__doc__), path.expanduser("~"), '*.*(*.*)'))).strip() + '" parsed %} ')
     elif action in 'templatetag':
         self.locator.get_service("editor").insert_text('{% templatetag ' + str(QInputDialog.getItem(None, __doc__, "Template Tag tags:", ['openblock', 'openvariable', 'openbrace', 'opencomment'], 0, False)[0]) + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + '{% templatetag ' + str(QInputDialog.getItem(None, __doc__, "Template Tag tags:", ['closeblock', 'closevariable', 'closebrace', 'closecomment'], 0, False)[0]) + ' %} ')
     elif action in 'url':
         self.locator.get_service("editor").insert_text('{% url ' + str(QInputDialog.getText(None, __doc__, "View method name string and optional variables:", text='"path.to.some_view" variable1 variable2')[0]).strip() + ' %} ')
     elif action in 'verbatim':
         self.locator.get_service("editor").insert_text('{% verbatim %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endverbatim %}')
     elif action in 'widthratio':
         self.locator.get_service("editor").insert_text(' {% widthratio' + ' {} {} {} '.format(QInputDialog.getText(None, __doc__, "Variable or String to use as Value:", text='variable')[0], QInputDialog.getText(None, __doc__, "Variable or String to use as Maximum Value:", text='max_value')[0], QInputDialog.getText(None, __doc__, "Variable or String to use as Maximum Width:", text='max_width')[0]) + ' %} ')
     elif action in 'with':
         self.locator.get_service("editor").insert_text(' {% width ' + str(QInputDialog.getText(None, __doc__, "One or Multiple Variables to Cache on the View, key=value space separated:", text='variable1=foo.bar variable2=bar.baz')[0]).strip() + ' %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endwidth %}')
     elif action in 'add':
         self.locator.get_service("editor").insert_text('|add:{} '.format(QInputDialog.getText(None, __doc__, "Variable or String to Add:", text='variable')[0]))
     elif action in 'addslashes':
         self.locator.get_service("editor").insert_text('|addslashes ')
     elif action in 'capfirst':
         self.locator.get_service("editor").insert_text('|capfirst ')
     elif action in 'center':
         self.locator.get_service("editor").insert_text('|center:"{}" '.format(int(QInputDialog.getInteger(None, __doc__, "Number of spaces to center:", 10, 1, 99, 1)[0])))
     elif action in 'cut':
         self.locator.get_service("editor").insert_text('|cut:"{}" '.format(QInputDialog.getText(None, __doc__, "Characters to Cut:", text=' ')[0]))
     elif action in 'date':
         self.locator.get_service("editor").insert_text('|date:"' + str(QInputDialog.getItem(None, __doc__, "Date Time format:", ['DATETIME_FORMAT', 'SHORT_DATETIME_FORMAT', 'SHORT_DATE_FORMAT', 'DATE_FORMAT'], 0, False)[0]) + '" ')
     elif action in 'default':
         self.locator.get_service("editor").insert_text('|default:"{}" '.format(QInputDialog.getText(None, __doc__, "String if evaluates as False:", text='nothing')[0]))
     elif action in 'default_if_none':
         self.locator.get_service("editor").insert_text('|default_if_none:"{}" '.format(QInputDialog.getText(None, __doc__, "String if None:", text='nothing')[0]))
     elif action in 'dictsort':
         self.locator.get_service("editor").insert_text('|dictsort:"{}" '.format(QInputDialog.getText(None, __doc__, "Sort List of Dicts by given Key:", text='key')[0]))
     elif action in 'dictsortreversed':
         self.locator.get_service("editor").insert_text('|dictsortreversed:"{}" '.format(QInputDialog.getText(None, __doc__, "Sort and Reverse List of Dicts by given Key:", text='key')[0]))
     elif action in 'divisibleby':
         self.locator.get_service("editor").insert_text('|divisibleby:"{}" '.format(int(QInputDialog.getInteger(None, __doc__, "Return True if its Divisible by:", 10, 1, 99, 1)[0])))
     elif action in 'escape':
         self.locator.get_service("editor").insert_text('|escape ')
     elif action in 'escapejs':
         self.locator.get_service("editor").insert_text('|escapejs ')
     elif action in 'filesizeformat':
         self.locator.get_service("editor").insert_text('|filesizeformat ')
     elif action in 'first':
         self.locator.get_service("editor").insert_text('|first ')
     elif action in 'fix_ampersands':
         self.locator.get_service("editor").insert_text('|fix_ampersands ')
     elif action in 'floatformat':
         self.locator.get_service("editor").insert_text('|floatformat:"{}" '.format(int(QInputDialog.getInteger(None, __doc__, "How many Decimals:", 10, 1, 99, 1)[0])))
     elif action in 'force_escape':
         self.locator.get_service("editor").insert_text('|force_escape ')
     elif action in 'get_digit':
         self.locator.get_service("editor").insert_text('|get_digit:"{}" '.format(int(QInputDialog.getInteger(None, __doc__, "Return string index of integer digit:", 10, 1, 99, 1)[0])))
     elif action in 'iriencode':
         self.locator.get_service("editor").insert_text('|iriencode ')
     elif action in 'join':
         self.locator.get_service("editor").insert_text('|join:"{}" '.format(QInputDialog.getText(None, __doc__, "Join values by:", text='//')[0]))
     elif action in 'last':
         self.locator.get_service("editor").insert_text('|last ')
     elif action in 'lenght':
         self.locator.get_service("editor").insert_text('|lenght ')
     elif action in 'lenght_is':
         self.locator.get_service("editor").insert_text('|lenght_is:"{}" '.format(int(QInputDialog.getInteger(None, __doc__, "Return True is lenght is:", 10, 1, 99, 1)[0])))
     elif action in 'linebreaks':
         self.locator.get_service("editor").insert_text('|linebreaks ')
     elif action in 'linebreaksbr':
         self.locator.get_service("editor").insert_text('|linebreaksbr ')
     elif action in 'linenumbers':
         self.locator.get_service("editor").insert_text('|linenumbers ')
     elif action in 'ljust':
         self.locator.get_service("editor").insert_text('|ljust:"{}" '.format(int(QInputDialog.getInteger(None, __doc__, "How many Spaces to Justify to the Left:", 10, 1, 99, 1)[0])))
     elif action in 'lower':
         self.locator.get_service("editor").insert_text('|lower ')
     elif action in 'make_list':
         self.locator.get_service("editor").insert_text('|make_list ')
     elif action in 'phone2numeric':
         self.locator.get_service("editor").insert_text('|phone2numeric ')
     elif action in 'pluralize':
         self.locator.get_service("editor").insert_text('|pluralize ')
     elif action in 'pprint':
         self.locator.get_service("editor").insert_text('|pprint ')
     elif action in 'random':
         self.locator.get_service("editor").insert_text('|random ')
     elif action in 'removetags':
         self.locator.get_service("editor").insert_text('|removetags:"{}" '.format(QInputDialog.getText(None, __doc__, "HTML Tags to remove, space separated:", text='b strong')[0]))
     elif action in 'rjust':
         self.locator.get_service("editor").insert_text('|rjust:"{}" '.format(int(QInputDialog.getInteger(None, __doc__, "How many Spaces to Justify to the Right:", 10, 1, 99, 1)[0])))
     elif action in 'safe':
         self.locator.get_service("editor").insert_text('|safe ')
     elif action in 'safeseq':
         self.locator.get_service("editor").insert_text('|safeseq ')
     elif action in 'slice':
         self.locator.get_service("editor").insert_text('|slice:"{}" '.format(QInputDialog.getText(None, __doc__, "Perform Python like Slice by:", text=':5')[0]))
     elif action in 'slugify':
         self.locator.get_service("editor").insert_text('|slugify ')
     elif action in 'stringformat':
         self.locator.get_service("editor").insert_text('|stringformat:"{}" '.format(QInputDialog.getText(None, __doc__, "Perform Python like String Format:")[0]))
     elif action in 'striptags':
         self.locator.get_service("editor").insert_text('|striptags ')
     elif action in 'time':
         self.locator.get_service("editor").insert_text('|time:"' + str(QInputDialog.getItem(None, __doc__, "Date Time format:", ['DATETIME_FORMAT', 'SHORT_DATETIME_FORMAT', 'SHORT_DATE_FORMAT', 'DATE_FORMAT'], 0, False)[0]) + '" ')
     elif action in 'timesince':
         self.locator.get_service("editor").insert_text('|timesince ')
     elif action in 'timeuntil':
         self.locator.get_service("editor").insert_text('|timeuntil ')
     elif action in 'title':
         self.locator.get_service("editor").insert_text('|title ')
     elif action in 'truncatechars':
         self.locator.get_service("editor").insert_text('|truncatechars:{} '.format(int(QInputDialog.getInteger(None, __doc__, "Truncate by how many Chars:", 10, 1, 99, 1)[0])))
     elif action in 'truncatewords':
         self.locator.get_service("editor").insert_text('|truncatewords:{} '.format(int(QInputDialog.getInteger(None, __doc__, "Truncate by how many Words:", 10, 1, 99, 1)[0])))
     elif action in 'truncatewords_html':
         self.locator.get_service("editor").insert_text('|truncatewords_html:{} '.format(int(QInputDialog.getInteger(None, __doc__, "Truncate by how many Words with HTML:", 10, 1, 99, 1)[0])))
     elif action in 'unordered_list':
         self.locator.get_service("editor").insert_text('|unordered_list ')
     elif action in 'upper':
         self.locator.get_service("editor").insert_text('|upper ')
     elif action in 'urlencode':
         self.locator.get_service("editor").insert_text('|urlencode ')
     elif action in 'urlize':
         self.locator.get_service("editor").insert_text('|urlize ')
     elif action in 'urlizetrunc':
         self.locator.get_service("editor").insert_text('|urlizetrunc ')
     elif action in 'wordcount':
         self.locator.get_service("editor").insert_text('|wordcount ')
     elif action in 'wordwrap':
         self.locator.get_service("editor").insert_text('|wordwrap:{} '.format(int(QInputDialog.getInteger(None, __doc__, "Wrap by how many Words:", 10, 1, 99, 1)[0])))
     elif action in 'yesno':
         self.locator.get_service("editor").insert_text('|yesno:"{}" '.format(QInputDialog.getText(None, __doc__, "Maps values for True, False and (optionally) None, to Strings:", text='yes,no,maybe')[0]))
     elif action in 'apnumber':
         self.locator.get_service("editor").insert_text(' | apnumber ')
     elif action in 'intcomma':
         self.locator.get_service("editor").insert_text(' | intcomma ')
     elif action in 'intword':
         self.locator.get_service("editor").insert_text(' | intword ')
     elif action in 'naturalday':
         self.locator.get_service("editor").insert_text(' | naturalday ')
     elif action in 'naturaltime':
         self.locator.get_service("editor").insert_text(' | naturaltime ')
     elif action in 'ordinal':
         self.locator.get_service("editor").insert_text(' | ordinal ')
     elif action in 'lorem':
         self.locator.get_service("editor").insert_text('{% lorem ' + str(int(QInputDialog.getInteger(None, __doc__, "Number of paragraphs or words to generate:", 10, 1, 99, 1)[0])) + ' p %}')
     elif action in 'static':
         self.locator.get_service("editor").insert_text('{% static "' + str(QInputDialog.getText(None, __doc__, "Relative Path to Static File:", text='img/icon.png')[0]).strip() + '" %} ')
     elif action in 'staticfile':
         self.locator.get_service("editor").insert_text('{% static "' + str(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open File".format(__doc__), path.expanduser("~"), '*.*(*.*)'))).strip() + '" %} ')
     elif action in 'get_static_prefix':
         self.locator.get_service("editor").insert_text('{% get_static_prefix %}')
     elif action in 'get_media_prefix':
         self.locator.get_service("editor").insert_text('{% get_media_prefix %}')
     elif action in 'singlelinecomment':
         self.locator.get_service("editor").insert_text('{# ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' #}')
     elif action in 'multilinecomment':
         self.locator.get_service("editor").insert_text('{% comment %} ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' {% endcomment %}')
     elif action in 'singlelinecommentpopup':
         self.locator.get_service("editor").insert_text('{# ' + str(QInputDialog.getText(None, __doc__, "Type a New Django Template Comment:")[0]).strip() + ' #}')
     elif action in 'multilinecommentpopup':
         dialog, group0, stringy = QDialog(), QGroupBox(), QTextEdit()
         group0.setTitle(__doc__)
         button, glow = QPushButton(' OK '), QGraphicsDropShadowEffect()
         button.setMinimumSize(200, 50)
         button.clicked.connect(lambda: self.locator.get_service("editor").insert_text('{% comment %} ' + str(stringy.toPlainText()).strip() + ' {% endcomment %}'))
         button.released.connect(lambda: dialog.close())
         glow.setOffset(0)
         glow.setBlurRadius(99)
         glow.setColor(QColor(99, 255, 255))
         button.setGraphicsEffect(glow)
         vboxg0 = QVBoxLayout(group0)
         for each_widget in (QLabel('<b>Multiline Comment'), stringy, button):
             vboxg0.addWidget(each_widget)
         QVBoxLayout(dialog).addWidget(group0)
         dialog.show()
     elif action in 'singlelinecommentclipboard':
         self.locator.get_service("editor").insert_text('{# ' + str(QApplication.clipboard().text().encode("utf-8")).strip() + ' #}')
     elif action in 'multilinecommentclipboard':
         self.locator.get_service("editor").insert_text('{% comment %} ' + str(QApplication.clipboard().text().encode("utf-8")).strip() + ' {% endcomment %}')
     elif action in 'multilinecommentfile':
         with open(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open File".format(__doc__), path.expanduser("~"), '*.*(*.*)')),  'r') as f:
             self.locator.get_service("editor").insert_text('{% comment %} ' + f.read() + ' {% endcomment %}')
     elif action in 'singlelinecommentdatetime':
         self.locator.get_service("editor").insert_text('{# ' + datetime.now().isoformat().split('.')[0] + ' by ' + getuser() + ' #}')
     elif action in 'htmlcomment':
         self.locator.get_service("editor").insert_text('<!-- ' + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' -->')
     elif action in 'iecomment':
         self.locator.get_service("editor").insert_text('<!--[if {} IE {}]> '.format(str(QInputDialog.getItem(None, __doc__, "Conditional format:", ['lte', 'lt', 'gt', 'gte'], 0, False)[0]), str(int(QInputDialog.getInteger(None, __doc__, "MS Internet Explorer Version:", 7, 5, 10, 1)[0])))  + str(self.locator.get_service("editor").get_actual_tab().textCursor().selectedText().encode("utf-8")) + ' <![endif]-->')
Example #27
0
 def initialize(self, *args, **kwargs):
     " Init Main Class "
     super(Main, self).initialize(*args, **kwargs)
     self.locator.get_service("menuApp").add_action(QAction(QIcon.fromTheme("edit-select-all"), "CSV to JSON", self, triggered=lambda: self.locator.get_service("editor").add_editor(content=dumps(list(reader(open(path.abspath(QFileDialog.getOpenFileName(None, "{} - Open a CSV File".format(__doc__), path.expanduser("~"), 'CSV(*.csv)'))))), indent=int(QInputDialog.getInteger(None, __doc__, "JSON Indentation Spaces:", 4, 0, 8, 2)[0]), sort_keys=True), syntax='python')))
Example #28
0
 def SeacherButton(self):
     newWidth, ok = QInputDialog.getInteger(self, self.tr("Select Entry"),
                                            self.tr("Entry range1-212964:"))
     if ok:
         self.id=newWidth
         self.updatePlots()