Exemple #1
0
    def drawPreWorld(self, visualizer):
        blocks = self.level.blockHeights
        width, height = len(blocks), len(blocks[0])

        furthest = max([self.distances[n] for n in itertools.chain(*self.terrain) if n])

        for i, j in itertools.product(range(width), range(height)):            
            # average weights of edges connected to this node
            sum, count = 0, 0
            node = self.terrain[j][i]
            if node:
                for offset in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
                    ni, nj = i + offset[0], j + offset[1]
                    if ni < 0 or ni >= width or nj < 0 or nj >= height:
                        continue
                    neighbour = self.terrain[nj][ni]
                    if neighbour:
                        sum, count = sum + self.graph[node][neighbour]['weight'], count + 1
            if count:
                d = sum / count
            else:
                d = 32

            if self.level.blockHeights[i][j] == 1:
                visualizer.drawPixel((i, j), QtGui.qRgb(196, 196, 196))
            elif self.level.blockHeights[i][j] >= 2:            
                visualizer.drawPixel((i, j), QtGui.qRgb(64, 64, 64))
            else:
                visualizer.drawPixel((i, j), QtGui.qRgb(d,d,d))
    def _update_font(self):
        px_size = 2
        px_space = 2

        lcd_bg = QtGui.qRgb(0, 0, 20)
        lcd_off = QtGui.qRgb(60, 40, 20)
        lcd_on = QtGui.qRgb(250, 220, 20)

        def render_char(c):
            # Create QImage
            im = QtGui.QImage(
                5*(px_size+px_space) + px_space,
                8*(px_size+px_space) + px_space,
                QtGui.QImage.Format_RGB32
            )
            im.fill(lcd_bg)

            p = QtGui.QPainter()
            assert p.begin(im)
            for r_idx, r_def in enumerate((list(c) + [0]*8)[:8]):
                for c_idx in range(5):
                    c = lcd_off if r_def & (1<<(4-c_idx)) == 0 else lcd_on
                    p.fillRect(
                        (px_space+px_size)*c_idx + px_space,
                        (px_space+px_size)*r_idx + px_space,
                        px_size, px_size, c
                    )
            p.end()

            return im

        # render char rom font
        self._font = list(render_char(c) for c in CHAR_ROM)
        self.updateGeometry()
Exemple #3
0
 def drawPreBots(self, visualizer):
     for p, o in self.ambushes:
         visualizer.drawCircle(p, QtGui.qRgb(255,255,0), 0.5)
         visualizer.drawRay(p, o, QtGui.qRgb(255,0,0))
     for island in self.islandEdges:
         for p, _ in island:
             visualizer.drawCircle(p, QtGui.qRgb(255,0,0), 0.5)
Exemple #4
0
    def grayScale(self, image):
        for i in range(self.w):
            for j in range(self.h):
                c = image.pixel(i, j)
                gray = QtGui.qGray(c)
                alpha = QtGui.qAlpha(c)
                image.setPixel(i, j, QtGui.qRgba(gray, gray, gray, alpha))

        return image
def to_grayscaled(path):
    origin = QtGui.QPixmap(path)

    img = origin.toImage()
    for i in xrange(origin.width()):
        for j in xrange(origin.height()):
            col = img.pixel(i, j)
            gray = QtGui.qGray(col)
            img.setPixel(i, j, QtGui.qRgb(gray, gray, gray))

    dst = origin.fromImage(img)
    return dst
    def drawWorld(self):
        if hasattr(self.commander, 'preWorldHook'):
            self.commander.preWorldHook(self)

        for i, j in itertools.product(range(self.levelWidth), range(self.levelHeight)):
            if self.commander.level.blockHeights[i][j] == 1:
                self.drawPixel((i, j), QtGui.qRgb(101, 91, 80))
            elif self.commander.level.blockHeights[i][j] >= 2:
                self.drawPixel((i, j), QtGui.qRgb(47, 44, 32))

        if hasattr(self.commander, 'postWorldHook'):
            self.commander.postWorldHook(self)
Exemple #7
0
    def resizeImage(self, image, newSize):
        if image.size() == newSize:
            return

#       print "image.size() = %s" % repr(image.size())
#       print "newSize = %s" % newSize

# this resizes the canvas without resampling the image
        newImage = QtGui.QImage(newSize, QtGui.QImage.Format_RGB32)
        newImage.fill(QtGui.qRgb(255, 255, 255))
        painter = QtGui.QPainter(newImage)
        painter.drawImage(QtCore.QPoint(0, 0), image)


##  this resampled the image but it gets messed up with so many events...       
##      painter.setRenderHint(QtGui.QPainter.SmoothPixmapTransform, True)
##      painter.setRenderHint(QtGui.QPainter.HighQualityAntialiasing, True)
#       
#       newImage = QtGui.QImage(newSize, QtGui.QImage.Format_RGB32)
#       newImage.fill(QtGui.qRgb(255, 255, 255))
#       painter = QtGui.QPainter(newImage)
#       srcRect = QtCore.QRect(QtCore.QPoint(0,0), image.size())
#       dstRect = QtCore.QRect(QtCore.QPoint(0,0), newSize)
##      print "srcRect = %s" % srcRect
##      print "dstRect = %s" % dstRect
#       painter.drawImage(dstRect, image, srcRect)


        self.image = newImage
 def export_height_map(self):
     name = QtGui.QFileDialog.getSaveFileName(self,
         'Export Heightmap', filter = IMAGE_SAVE_FILTER)[0]
     if not name:
         return
     height_packed = []
     for z in xrange(0, 64):
         height = (63 - z) * 4
         height_packed.append(struct.pack('I', QtGui.qRgba(height, height, height, 255)))
     height_image = QImage(512, 512, QImage.Format_ARGB32)
     height_lines = []
     height_found = []
     for y in xrange(0, 512):
         height_lines.append(height_image.scanLine(y))
         height_found.append([])
         for x in xrange(0, 512):
             height_found[y].append(False)
     progress = progress_dialog(self.edit_widget, 0, 63, 'Exporting Heightmap...')
     for z in xrange(0, 64):
         if progress.wasCanceled():
             break
         progress.setValue(z)
         packed_value = height_packed[z]
         image = self.layers[z]
         for y in xrange(0, 512):
             image_line = image.scanLine(y)
             height_line = height_lines[y]
             for x in xrange(0, 512):
                 if height_found[y][x] is False:
                     s = x * 4
                     if image_line[s:s + 4] != TRANSPARENT_PACKED:
                         height_found[y][x] = True
                         height_line[s:s + 4] = packed_value
     height_image.save(name)
    def __init__(self, text, font, position, maxSize, alpha=0):
        DisplayShape.__init__(self, position, maxSize)

        self.alpha = alpha
        self.textDocument = QtGui.QTextDocument()

        self.textDocument.setHtml(text)
        self.textDocument.setDefaultFont(font)
        self.textDocument.setPageSize(maxSize)
        documentSize = self.textDocument.documentLayout().documentSize()
        self.setSize(QtCore.QSizeF(self.maxSize.width(), min(self.maxSize.height(), documentSize.height())))

        self.source = QtGui.QImage(int(ceil(documentSize.width())),
                                   int(ceil(documentSize.height())),
                                   QtGui.QImage.Format_ARGB32_Premultiplied)
        self.source.fill(QtGui.qRgba(255, 255, 255, 255))

        context = QtGui.QAbstractTextDocumentLayout.PaintContext()
        self.textDocument.documentLayout().setPaintDevice(self.source)

        painter = QtGui.QPainter()
        painter.begin(self.source)
        painter.setRenderHint(QtGui.QPainter.TextAntialiasing)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        self.textDocument.documentLayout().draw(painter, context)
        painter.end()

        self.source = self.source.scaled(int(ceil(self.maxSize.width())),
                                         int(ceil(self.maxSize.height())),
                                         QtCore.Qt.KeepAspectRatio,
                                         QtCore.Qt.SmoothTransformation)

        self.image = QtGui.QImage(self.source.size(), self.source.format())
        self.redraw()
    def postWorldHook(self, visualizer):
        """
        Will draw a graphical representation of the corridor map on to the
        visualisation window.
        """
        for s, f in self.corridor_graph.edges():
            visualizer.drawLine(self.corridor_graph.node[s]["position"],
                                self.corridor_graph.node[f]["position"],
                                QtGui.qRgb(255, 255, 255))

        for n in self.corridor_graph.nodes():
            visualizer.drawCircle(self.corridor_graph.node[n]["position"],
                                  QtGui.qRgb(255, 255, 255))
            if self.explored[n]:
                visualizer.drawCircle(self.corridor_graph.node[n]["position"],
                                      QtGui.qRgb(0, 0, 0), scale=0.8)
 def addImage(self):
     newSize = QtCore.QSize(531, 671)
     newImage = QtGui.QImage(newSize, QtGui.QImage.Format_RGB32)
     newImage.fill(QtGui.qRgb(255, 255, 255))
     painter = QtGui.QPainter(newImage)
     painter.drawImage(QtCore.QPoint(0, 0), self.image)
     self.image = newImage     
Exemple #12
0
	def __init__( self, parent = None ) :
		# Initialise QWidget
		super( QtVmbViewer, self ).__init__( parent )
		# Set the window title
		self.setWindowTitle( 'StereoVision' )
		# Connect the signal to update the image
		self.update_image.connect( self.UpdateImage )
		# Widget to display the images from the cameras
		self.image_widget = QtGui.QLabel( self )
		self.image_widget.setScaledContents( True )
		# Widget layout
		self.layout = QtGui.QVBoxLayout( self )
		self.layout.addWidget( self.image_widget )
		self.layout.setSizeConstraint( QtGui.QLayout.SetFixedSize )
		# Set the Escape key to close the application
		QtGui.QShortcut( QtGui.QKeySequence( QtCore.Qt.Key_Escape ), self ).activated.connect( self.close )
		# Initialize Vimba
		Vimba.VmbStartup()
		# Initialize the camera
		self.camera = Vimba.VmbCamera( Vimba.VmbCamerasList()[0].cameraIdString )
		# Open the camera
		self.camera.Open()
		# Create a QImage to store the image from the camera
		self.image = QtGui.QImage( self.camera.width, self.camera.height, QtGui.QImage.Format_Indexed8 )
		# Create a indexed color table
		self.image.setColorCount(256)
		for i in range( 256 ) : self.image.setColor( i, QtGui.qRgb(i, i, i) )
		# Start image acquisition
		self.camera.StartCapture(  self.ImageCallback  )
Exemple #13
0
    def rgbFromWaveLength(self, wave):
        r = 0.0
        g = 0.0
        b = 0.0

        if wave >= 380.0 and wave <= 440.0:
            r = -1.0 * (wave - 440.0) / (440.0 - 380.0)
            b = 1.0
        elif wave >= 440.0 and wave <= 490.0:
            g = (wave - 440.0) / (490.0 - 440.0)
            b = 1.0
        elif wave >= 490.0 and wave <= 510.0:
            g = 1.0
            b = -1.0 * (wave - 510.0) / (510.0 - 490.0)
        elif wave >= 510.0 and wave <= 580.0:
            r = (wave - 510.0) / (580.0 - 510.0)
            g = 1.0
        elif wave >= 580.0 and wave <= 645.0:
            r = 1.0
            g = -1.0 * (wave - 645.0) / (645.0 - 580.0)
        elif wave >= 645.0 and wave <= 780.0:
            r = 1.0

        s = 1.0
        if wave > 700.0:
            s = 0.3 + 0.7 * (780.0 - wave) / (780.0 - 700.0)
        elif wave < 420.0:
            s = 0.3 + 0.7 * (wave - 380.0) / (420.0 - 380.0)

        r = pow(r * s, 0.8)
        g = pow(g * s, 0.8)
        b = pow(b * s, 0.8)

        return QtGui.qRgb(int(r*255), int(g*255), int(b*255))
Exemple #14
0
    def __init__(self, text, parent):
        super(DragLabel, self).__init__(parent)

        metric = QtGui.QFontMetrics(self.font())
        size = metric.size(QtCore.Qt.TextSingleLine, text)

        image = QtGui.QImage(size.width() + 12, size.height() + 12,
                QtGui.QImage.Format_ARGB32_Premultiplied)
        image.fill(QtGui.qRgba(0, 0, 0, 0))

        font = QtGui.QFont()
        font.setStyleStrategy(QtGui.QFont.ForceOutline)

        painter = QtGui.QPainter()
        painter.begin(image)
        painter.setRenderHint(QtGui.QPainter.Antialiasing)
        painter.setBrush(QtCore.Qt.white)
        painter.drawRoundedRect(QtCore.QRectF(0.5, 0.5, image.width()-1,
                image.height()-1), 25, 25, QtCore.Qt.RelativeSize)

        painter.setFont(font)
        painter.setBrush(QtCore.Qt.black)
        painter.drawText(QtCore.QRect(QtCore.QPoint(6, 6), size),
                QtCore.Qt.AlignCenter, text)
        painter.end()

        self.setPixmap(QtGui.QPixmap.fromImage(image))
        self.labelText = text
    def redraw(self):
        self.image.fill(QtGui.qRgba(self.alpha, self.alpha, self.alpha, self.alpha))

        painter = QtGui.QPainter()
        painter.begin(self.image)
        painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn)
        painter.drawImage(0, 0, self.source)
        painter.end()
    def paintEvent(self, event):
        super(ScreenView, self).paintEvent(event)

        fw = self.frameWidth()
        fm = self.fontMetrics()

        p = QtGui.QPainter(self)

        p.fillRect(
            self.frameRect().adjusted(-fw, -fw, -fw, -fw),
            QtGui.qRgb(40, 40, 40)
        )

        if self._screen is None:
            return

        cw, ch = fm.width('X'), fm.lineSpacing()
        x0, y0 = fw, fw
        h, w = self._screen.size

        bg = QtGui.qRgb(0, 0, 0)
        fg = QtGui.qRgb(255, 255, 255)

        cbg = QtGui.qRgb(255, 255, 255)
        cfg = QtGui.qRgb(0, 0, 0)

        p.fillRect(x0, y0, w*cw, h*ch, bg)

        c = self._screen.cursor
        to = fm.ascent()
        for y, line in enumerate(self._screen.buffer):
            py = y * ch + y0
            for x, char in enumerate(line):
                p.setPen(fg)
                px = x * cw + x0

                if (x, y) == (c.x, c.y):
                    if self.hasFocus():
                        p.fillRect(px, py, cw, ch, cbg)
                        p.setPen(cfg)
                    else:
                        p.setPen(cbg)
                        p.drawRect(px, py, cw, ch)
                        p.setPen(fg)

                p.drawText(px, py + to, char.data)
Exemple #17
0
    def resizeImage(self, image, newSize):
        if image.size() == newSize:
            return

        newImage = QtGui.QImage(newSize, QtGui.QImage.Format_RGB32)
        newImage.fill(QtGui.qRgb(255, 255, 255))
        painter = QtGui.QPainter(newImage)
        painter.drawImage(QtCore.QPoint(0, 0), image)
        self.image = newImage
    def postWorldHook(self, visualizer):
        """
        Will draw a graphical representation of the corridor map on to the
        visualisation window.
        """
        for s, f in self.corridor_graph.edges():
            visualizer.drawLine(self.corridor_graph.node[s]["position"],
                                self.corridor_graph.node[f]["position"],
                                QtGui.qRgb(255, 255, 255))

        for n in self.corridor_graph.nodes():
            #visualizer.drawCircle(self.corridor_graph.node[n]["position"],
            #                      QtGui.qRgb(255, 255, 255))
            pos = self.corridor_graph.node[n]["position"]
            pos = Vector2(pos[0], pos[1])
            visualizer.drawText(pos, QtGui.qRgb(255, 255, 255), unicode(n))
            #if self.explored[n]:
                #visualizer.drawCircle(self.corridor_graph.node[n]["position"],
                                     # QtGui.qRgb(0, 0, 0), scale=0.8)

        height_separator = self.level.height / 2
        width_separator = self.level.width / 2

        graph_one = []
        graph_two = []
        graph_three = []
        graph_four = []
        for n in self.corridor_graph.nodes():
            position = self.corridor_graph.node[n]["position"]
            position = Vector2(position[0], position[1])
            if position.y > height_separator:
                if position.x > width_separator:
                    graph_one.append(n)
                else:
                    graph_two.append(n)
            else:
                if position.x > width_separator:
                    graph_three.append(n)
                else:
                    graph_four.append(n)

        graph_one = self.corridor_graph.subgraph(graph_one)
        for n in graph_one.nodes():
            visualizer.drawCircle(self.corridor_graph.node[n]["position"], QtGui.qRgb(255, 0, 0), scale=0.8)
Exemple #19
0
def interpolate_rgb(start_color, start_value, end_color, end_value, actual_value):
    delta_value = end_value - start_value
    if delta_value == 0.0:
        return start_color

    multiplier = (actual_value - start_value) / delta_value

    start_red = (start_color >> 16) & 0xff
    end_red = (end_color >> 16) & 0xff
    delta_red = end_red - start_red
    red = start_red + (delta_red * multiplier)

    if delta_red > 0:
        if red < start_red:
            red = start_red
        elif red > end_red:
            red = end_red
    else:
        if red > start_red:
            red = start_red
        elif red < end_red:
            red = end_red

    start_green = (start_color >> 8) & 0xff
    end_green = (end_color >> 8) & 0xff
    delta_green = end_green - start_green
    green = start_green + (delta_green * multiplier)

    if delta_green > 0:
        if green < start_green:
            green = start_green
        elif green > end_green:
            green = end_green
    else:
        if green > start_green:
            green = start_green
        elif green < end_green:
            green = end_green

    start_blue = start_color & 0xff
    end_blue = end_color & 0xff
    delta_blue = end_blue - start_blue
    blue = start_blue + (delta_blue * multiplier)

    if delta_blue > 0:
        if blue < start_blue:
            blue = start_blue
        elif blue > end_blue:
            blue = end_blue
    else:
        if blue > start_blue:
            blue = start_blue
        elif blue < end_blue:
            blue = end_blue

    return QtGui.qRgb(red, green, blue)
Exemple #20
0
    def drawPreWorld(visualizer):
        brightest = max([instance.visibilities.pixel(i,j) for i, j in itertools.product(range(88), range(50))])

        for i, j in itertools.product(range(88), range(50)):            
            n = instance.terrain[j][i]
            if n:
                if instance.mode == instance.MODE_VISIBILITY:
                    d = instance.visibilities.pixel(i,j) * 255 / (brightest+1)
            else:                
                d = 32
            visualizer.drawPixel((i, j), QtGui.qRgb(d,d,d))
    def prepareImage(self):
        # vytvoření instance třídy QImage
        self.image = QtGui.QImage(MainWindow.IMAGE_WIDTH,
                                  MainWindow.IMAGE_HEIGHT,
                                  QtGui.QImage.Format_RGB32)

        # vyplnění celého obrázku konstantní barvou
        self.image.fill(QtGui.qRgb(10, 80, 20))

        # vytvoření instance třídy QPixmap z objektu QImage
        self.pixmap = QtGui.QPixmap.fromImage(self.image)
Exemple #22
0
    def fillImage(self, plotRange, noPixels, iterN, colorMap):
        """
        This function fills the image with colors representing the mandelbrot
        iterations.

        Arguments:
        plotRange    -- The range in the complex plane to plot.
        noPixels     -- The number of pixels per bitmap side (int).
        iterN        -- Max number of manderbrot iterations.
        colorMap     -- The color map object.

        Return:
        The generated image.
        """

        # Create image object
        image = QtGui.QImage(noPixels,noPixels,QtGui.QImage.Format_RGB32)

        # iteration number
        itrNo = 1

        # Get list of complex numbers
        complexList = self.getPixelMap(noPixels,plotRange)

        # Send max number of iterations to progress bar
        self.sender.maxSignal.emit(noPixels*noPixels)

        # Iterate through all complex numbers and calculate the Mandelbrot
        # iterations.
        for i in range(noPixels):
            for j in range(noPixels):
                # Get complex number
                c = complexList[i][j]

                # Calculate number of iterations
                mIter = self.mandelbrotIterations(c,iterN)

                # Get color
                color = colorMap.getColor(mIter-1)

                # Plot Pixel
                if (i > noPixels) or (j > noPixels):
                    # Complex number is out of range
                    print("Error: Pixel index out of range!")
                else:
                    # Paint one pixel
                    image.setPixel(i,j,QtGui.qRgb(color[0],color[1],color[2]))

                # Emit signal and increase iteration number
                self.sender.itrSignal.emit(itrNo)
                itrNo += 1

        return image
Exemple #23
0
    def drawGame(self):
        if hasattr(self.commander, 'preGameHook'):
            self.commander.preGameHook(self)

        if self.drawBots:
            for name, bot in self.commander.game.bots.items():
                if bot.position is None:
                    continue

                if 'Red' in name:
                    if bot.seenlast > 0.0:
                        color = QtGui.qRgb(140,0,0)
                    else:
                        color = QtGui.qRgb(255,32,32)
                    if bot.health <= 0.0:
                        color = QtGui.qRgb(48,0,0)
                else:
                    if bot.seenlast > 0.0:
                        color = QtGui.qRgb(0,32,140)
                    else:
                        color = QtGui.qRgb(0,64,255)
                    if bot.health <= 0.0:
                        color = QtGui.qRgb(0,0,48)

                self.drawCircle(bot.position, color)
                self.drawRay(bot.position, bot.facingDirection, color)

        if hasattr(self.commander, 'postGameHook'):
            self.commander.postGameHook(self)
    def add(self):
        print self.imageString
        if self.imageString:
            print "Processing"
            im = Image.open(self.imageString)
            imdata = im.tostring()
            imWidth = im.size[0]
            imHeight = im.size[1]

            # Convert image data from PIL image into a QImage
            ################################################
            newqim = QtGui.QImage(imWidth, imHeight, QtGui.QImage.Format_ARGB32)
            for xstep in range(0,imWidth-1):
                for ystep in range(0,imHeight-1):
                    # PIL uses getpixel and putpixel
                    pixelValueTuple = im.getpixel((xstep,ystep))
                    pixelR = pixelValueTuple[0]
                    pixelG = pixelValueTuple[1]
                    pixelB = pixelValueTuple[2]
                    
                    addValue = self.sliderValue
                    pixelR += addValue
                    pixelG += addValue
                    pixelB += addValue
              
                    if pixelR > 255:
                        pixelR = 255
                    if pixelG > 255:
                        pixelG = 255
                    if pixelB > 255:
                        pixelB = 255
                        
                    if pixelR < 0:
                        pixelR = 0
                    if pixelG < 0:
                        pixelG = 0
                    if pixelB < 0:
                        pixelB = 0
                    
                    copiedValue = QtGui.qRgb(pixelR, pixelG, pixelB)
                    # QImage uses pixel and setpixel
                    newqim.setPixel(xstep, ystep, copiedValue)
            
                #newqim.save('result.jpg')

                # Put image data in a pixmap for display.
                # PIL Images and QImages may be used for read, write, manipulate.
                # QPixmaps are used for Qt GUI display.
                ################################################
                #pix = QPixmap.fromImage(qim) # Pixmap for display using QImage
            pix = QtGui.QPixmap.fromImage(newqim)
            self.set_image(pix)
    def prepareImage(self):
        # vytvoření instance třídy QImage
        self.image = QtGui.QImage(MainWindow.IMAGE_WIDTH,
                                  MainWindow.IMAGE_HEIGHT,
                                  QtGui.QImage.Format_RGB32)

        # vyplnění celého obrázku barvovým přechodem
        for y in range(MainWindow.IMAGE_HEIGHT):
            for x in range(MainWindow.IMAGE_WIDTH):
                # zde dochází k přetečení hodnoty barvových složek
                # Red, Green, Blue
                self.image.setPixel(x, y, QtGui.qRgb(x, x*10, y))

        # vytvoření instance třídy QPixmap z objektu QImage
        self.pixmap = QtGui.QPixmap.fromImage(self.image)
Exemple #26
0
    def toQImage(self, im, copy=False):
        """ Conversion from a numpy array to a QImage """
        if im is None:
            return QtGui.QImage()

        gray_color_table = [QtGui.qRgb(i, i, i) for i in range(256)]

        if im.dtype == np.uint8 and len(im.shape) == 3:
            qim = QtGui.QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QtGui.QImage.Format_RGB888)
            return qim.rgbSwapped().copy() if copy else qim.rgbSwapped()
        elif im.dtype == np.uint8 and len(im.shape) == 1:
            qim = QtGui.QImage(im.data, im.shape[1], im.shape[0], im.strides[0], QtGui.QImage.Format_Indexed8)
            qim.setColorTable(gray_color_table)
            return qim.copy() if copy else qim
        else :
            raise RuntimeError("Player : cannot convert frame to QImage.")
    def contrast(self):
        print self.imageString
        if self.imageString:
            print "Processing"
            im = Image.open(self.imageString)
            imdata = im.tostring()
            imWidth = im.size[0]
            imHeight = im.size[1]
            
            factor = (self.sliderValue*2.0)/100.0

            # Convert image data from PIL image into a QImage
            ################################################
            newqim = QtGui.QImage(imWidth, imHeight, QtGui.QImage.Format_ARGB32)
            for xstep in range(0,imWidth-1):
                for ystep in range(0,imHeight-1):
                    # PIL uses getpixel and putpixel
                    pixelValueTuple = im.getpixel((xstep,ystep))
                    pixelR = pixelValueTuple[0]
                    pixelG = pixelValueTuple[1]
                    pixelB = pixelValueTuple[2]
                    
                    pixelR = (factor * (pixelR - 128)) + 128
                    pixelG = (factor * (pixelG - 128)) + 128
                    pixelB = (factor * (pixelB - 128)) + 128
              
                    if pixelR > 255:
                        pixelR = 255
                    if pixelG > 255:
                        pixelG = 255
                    if pixelB > 255:
                        pixelB = 255
                        
                    if pixelR < 0:
                        pixelR = 0
                    if pixelG < 0:
                        pixelG = 0
                    if pixelB < 0:
                        pixelB = 0
                    
                    copiedValue = QtGui.qRgb(pixelR, pixelG, pixelB)
                    # QImage uses pixel and setpixel
                    newqim.setPixel(xstep, ystep, copiedValue)
            
            pix = QtGui.QPixmap.fromImage(newqim)
            self.set_image(pix)                
Exemple #28
0
    def drawPreWorld(self, visualizer):
       furthest = max([self.distances[n] for n in itertools.chain(*self.terrain) if n])
       brightest = max([self.visibilities.pixel(i,j) for i, j in itertools.product(range(88), range(50))])
        
        # visible = QtGui.QImage(88, 50, QtGui.QImage.Format_ARGB32)
        # visible.fill(0)

       for i, j in itertools.product(range(88), range(50)):            
            n = self.terrain[j][i]
            if n:
                if self.mode == self.MODE_TRAVELLING:
                    d = self.distances[n] * 255.0 / furthest
                if self.mode == self.MODE_VISIBILITY:
                    d = self.visibilities.pixel(i,j) * 255 / brightest
            else:                
                d = 32
            visualizer.drawPixel((i, j), QtGui.qRgb(d,d,d))
Exemple #29
0
    def _updateThumbnail(self):
        if self.__value.width > 0 and self.__value.height > 0:
                self._qimage = QtGui.QImage(self._thumbnailSize, self._thumbnailSize, QtGui.QImage.Format_RGB32)
                for i in range(self._thumbnailSize):
                    for j in range(self._thumbnailSize):
                        if self.__value.pixelFormat == "RGB":
                                pixelColor = self.__value.sampleRGB("""RGB""", float(i)/(self._thumbnailSize - 1.0), float(j)/(self._thumbnailSize - 1.0))
                        elif self.__value.pixelFormat == "RGBA":
                                pixelColor = self.__value.sampleRGBA("""RGBA""", float(i)/(self._thumbnailSize - 1.0), float(j)/(self._thumbnailSize - 1.0))
                        pixelValue = QtGui.qRgb(pixelColor.r, pixelColor.g, pixelColor.b)
                        self._qimage.setPixel(i, j, pixelValue)

                self.tumbnailEditor.setPixmap(QtGui.QPixmap.fromImage(self._qimage))


        self._grid.addWidget(self.tumbnailEditor, 3, 0, 2, 2)
        self._grid.setRowStretch(4, 2)
    def prepareImage(self):
        # vytvoření instance třídy QImage
        self.image = QtGui.QImage(MainWindow.IMAGE_WIDTH,
                                  MainWindow.IMAGE_HEIGHT,
                                  QtGui.QImage.Format_RGB32)

        # vyplnění celého obrázku barvovým přechodem
        for y in range(MainWindow.IMAGE_HEIGHT):
            for x in range(MainWindow.IMAGE_WIDTH):
                self.image.setPixel(x, y, QtGui.qRgb(y, y, 0))

        transform = QtGui.QTransform()
        transform.rotate(30)

        self.image = self.image.transformed(transform)

        # vytvoření instance třídy QPixmap z objektu QImage
        self.pixmap = QtGui.QPixmap.fromImage(self.image)
Exemple #31
0
    def setupUi(self):
        """Bruh"""
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setGeometry(50, 50, 850, 425)
        self.setWindowTitle("ZeZe's TWTools - Coord Extractor")
        self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))

        """Background color"""
        self.backgroundPalette = QtGui.QPalette()
        self.backgroundColor = QtGui.QColor(217, 204, 170)
        self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(self.backgroundPalette)

        """Main layout & return to main menu button"""
        self.verticalLayout = QtGui.QVBoxLayout(self)

        self.buttonLayout = QtGui.QHBoxLayout(self)
        self.verticalLayout.addLayout(self.buttonLayout)
        self.returnButton = QtGui.QPushButton("  Return to the Main Menu  ", self)
        self.returnButton.clicked.connect(self.return_function)
        self.buttonLayout.addWidget(self.returnButton)
        self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.buttonLayout.addItem(self.buttonSpacer)

        """Line Spacer and line"""
        self.lineSpacer = QtGui.QSpacerItem(40, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.verticalLayout.addItem(self.lineSpacer)
        self.line = QtGui.QFrame(self)
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.verticalLayout.addWidget(self.line)

        """Text input label and edit"""
        self.Spacer = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(self.Spacer)
        self.inputLabel = QtGui.QLabel("Input text with coordinates here:")
        self.verticalLayout.addWidget(self.inputLabel)
        self.plainTextEdit = QtGui.QPlainTextEdit(self)
        self.verticalLayout.addWidget(self.plainTextEdit)

        """Coordinates output label and edit"""
        self.Spacer1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(self.Spacer1)
        self.outputLabel = QtGui.QLabel("Output coordinates magically appear here:")
        self.verticalLayout.addWidget(self.outputLabel)
        self.plainTextEdit_2 = QtGui.QPlainTextEdit(self)
        self.verticalLayout.addWidget(self.plainTextEdit_2)

        """Extract coordinates button"""
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.Spacer2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(self.Spacer2)
        self.extractButton = QtGui.QPushButton("  Extract Coordinates  ", self)
        self.extractButton.clicked.connect(self.extract_function)
        self.horizontalLayout.addWidget(self.extractButton)
Exemple #32
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(682, 518)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pathList = QtGui.QListWidget(self.centralwidget)
        self.pathList.setMinimumSize(QtCore.QSize(251, 241))
        self.pathList.setObjectName("pathList")
        self.horizontalLayout.addWidget(self.pathList)
        self.frame_2 = QtGui.QFrame(self.centralwidget)
        self.frame_2.setMinimumSize(QtCore.QSize(91, 271))
        self.frame_2.setMaximumSize(QtCore.QSize(91, 16777215))
        self.frame_2.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QtGui.QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
        self.cmdDown = QtGui.QPushButton(self.frame_2)
        self.cmdDown.setGeometry(QtCore.QRect(10, 50, 41, 28))
        self.cmdDown.setObjectName("cmdDown")
        self.cmdUp = QtGui.QPushButton(self.frame_2)
        self.cmdUp.setGeometry(QtCore.QRect(10, 10, 41, 28))
        self.cmdUp.setObjectName("cmdUp")
        self.cmdDelete = QtGui.QPushButton(self.frame_2)
        self.cmdDelete.setGeometry(QtCore.QRect(10, 240, 75, 23))
        self.cmdDelete.setObjectName("cmdDelete")
        self.cmdAdd = QtGui.QPushButton(self.frame_2)
        self.cmdAdd.setGeometry(QtCore.QRect(10, 210, 75, 23))
        self.cmdAdd.setObjectName("cmdAdd")
        self.horizontalLayout.addWidget(self.frame_2)
        self.verticalLayout_2.addLayout(self.horizontalLayout)
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.lineEdit = QtGui.QLineEdit(self.centralwidget)
        self.lineEdit.setMinimumSize(QtCore.QSize(0, 22))
        self.lineEdit.setMaximumSize(QtCore.QSize(16777215, 22))
        self.lineEdit.setObjectName("lineEdit")
        self.verticalLayout.addWidget(self.lineEdit)
        self.frame = QtGui.QFrame(self.centralwidget)
        self.frame.setMinimumSize(QtCore.QSize(529, 70))
        self.frame.setMaximumSize(QtCore.QSize(529, 70))
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.cmdSave = QtGui.QPushButton(self.frame)
        self.cmdSave.setGeometry(QtCore.QRect(10, 10, 75, 23))
        self.cmdSave.setObjectName("cmdSave")
        self.buttonBox = QtGui.QDialogButtonBox(self.frame)
        self.buttonBox.setGeometry(QtCore.QRect(170, 10, 229, 28))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.frame)
        self.verticalLayout_2.addLayout(self.verticalLayout)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), MainWindow.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), MainWindow.reject)
        QtCore.QObject.connect(self.pathList, QtCore.SIGNAL("itemClicked(QListWidgetItem*)"), MainWindow.itemclick)
        QtCore.QObject.connect(self.cmdAdd, QtCore.SIGNAL("clicked()"), MainWindow.additem)
        QtCore.QObject.connect(self.cmdDelete, QtCore.SIGNAL("clicked()"), MainWindow.removeitem)
        QtCore.QObject.connect(self.cmdSave, QtCore.SIGNAL("clicked()"), MainWindow.saveitem)
        QtCore.QObject.connect(self.cmdUp, QtCore.SIGNAL("clicked()"), MainWindow.moveup)
        QtCore.QObject.connect(self.cmdDown, QtCore.SIGNAL("clicked()"), MainWindow.movedown)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
Exemple #33
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        self.setWindowTitle('OpenWave-1KB V%s' % __version__)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("openwave.ico"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        #Waveform area.
        self.figure = plt.figure()
        self.figure.set_facecolor('white')

        self.canvas = FigureCanvas(self.figure)
        self.canvas.setMinimumSize(800, 400)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        #Zoom In/out and Capture Buttons
        self.zoomBtn = QtGui.QPushButton('Zoom')
        self.zoomBtn.setFixedSize(100, 30)
        self.zoomBtn.clicked.connect(self.toolbar.zoom)

        self.panBtn = QtGui.QPushButton('Pan')
        self.panBtn.setFixedSize(100, 30)
        self.panBtn.clicked.connect(self.toolbar.pan)

        self.homeBtn = QtGui.QPushButton('Home')
        self.homeBtn.setFixedSize(100, 30)
        self.homeBtn.clicked.connect(self.toolbar.home)

        self.captureBtn = QtGui.QPushButton('Capture')
        self.captureBtn.setFixedSize(100, 50)
        self.captureBtn.clicked.connect(self.captureAction)
        if (dso.connection_status == 0):
            self.captureBtn.setEnabled(False)

        #Type: Raw Data/Image
        self.typeBtn = QtGui.QPushButton('Raw Data')
        self.typeBtn.setToolTip("Switch to get raw data or image from DSO.")
        self.typeBtn.setFixedSize(120, 50)
        self.typeFlag = True  #Initial state -> Get raw data
        self.typeBtn.setCheckable(True)
        self.typeBtn.setChecked(True)
        self.typeBtn.clicked.connect(self.typeAction)

        #Channel Selection.
        self.ch1checkBox = QtGui.QCheckBox('CH1')
        self.ch1checkBox.setFixedSize(60, 30)
        self.ch2checkBox = QtGui.QCheckBox('CH2')
        self.ch2checkBox.setFixedSize(60, 30)
        if (dso.chnum == 4):
            self.ch3checkBox = QtGui.QCheckBox('CH3')
            self.ch3checkBox.setFixedSize(60, 30)
            self.ch4checkBox = QtGui.QCheckBox('CH4')
            self.ch4checkBox.setFixedSize(60, 30)

        #Set channel selection layout.
        self.selectLayout = QtGui.QHBoxLayout()
        self.selectLayout.addWidget(self.ch1checkBox)
        self.selectLayout.addWidget(self.ch2checkBox)
        if (dso.chnum == 4):
            self.selectLayout2 = QtGui.QHBoxLayout()
            self.selectLayout2.addWidget(self.ch3checkBox)
            self.selectLayout2.addWidget(self.ch4checkBox)

        self.typeLayout = QtGui.QHBoxLayout()
        self.typeLayout.addWidget(self.typeBtn)
        self.typeLayout.addLayout(self.selectLayout)
        if (dso.chnum == 4):
            self.typeLayout.addLayout(self.selectLayout2)

        #Save/Load/Quit button
        self.saveBtn = QtGui.QPushButton('Save')
        self.saveBtn.setFixedSize(100, 50)
        self.saveMenu = QtGui.QMenu(self)
        self.csvAction = self.saveMenu.addAction("&As CSV File")
        self.pictAction = self.saveMenu.addAction("&As PNG File")
        self.saveBtn.setMenu(self.saveMenu)
        self.saveBtn.setToolTip("Save waveform to CSV file or PNG file.")
        self.connect(self.csvAction, QtCore.SIGNAL("triggered()"),
                     self.saveCsvAction)
        self.connect(self.pictAction, QtCore.SIGNAL("triggered()"),
                     self.savePngAction)

        self.loadBtn = QtGui.QPushButton('Load')
        self.loadBtn.setToolTip("Load CHx's raw data from file(*.csv, *.lsf).")
        self.loadBtn.setFixedSize(100, 50)
        self.loadBtn.clicked.connect(self.loadAction)

        self.quitBtn = QtGui.QPushButton('Quit')
        self.quitBtn.setFixedSize(100, 50)
        self.quitBtn.clicked.connect(self.quitAction)

        # set the layout
        self.waveLayout = QtGui.QHBoxLayout()
        self.waveLayout.addWidget(self.canvas)

        self.wave_box = QtGui.QVBoxLayout()
        self.wave_box.addLayout(self.waveLayout)

        self.wavectrlLayout = QtGui.QHBoxLayout()
        self.wavectrlLayout.addWidget(self.zoomBtn)
        self.wavectrlLayout.addWidget(self.panBtn)
        self.wavectrlLayout.addWidget(self.homeBtn)
        self.wavectrlLayout.addWidget(self.captureBtn)

        self.saveloadLayout = QtGui.QHBoxLayout()
        self.saveloadLayout.addWidget(self.saveBtn)
        self.saveloadLayout.addWidget(self.loadBtn)
        self.saveloadLayout.addWidget(self.quitBtn)

        self.ctrl_box = QtGui.QHBoxLayout()
        self.ctrl_box.addLayout(self.typeLayout)
        self.ctrl_box.addLayout(self.saveloadLayout)

        main_box = QtGui.QVBoxLayout()
        main_box.addLayout(self.wave_box)  #Waveform area.
        main_box.addLayout(self.wavectrlLayout)  #Zoom In/Out...
        main_box.addLayout(self.ctrl_box)  #Save/Load/Quit
        self.setLayout(main_box)
Exemple #34
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(588, 400)
        self.buttonBox = QtGui.QDialogButtonBox(Dialog)
        self.buttonBox.setGeometry(QtCore.QRect(100, 370, 341, 32))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setCenterButtons(True)
        self.buttonBox.setObjectName("buttonBox")
        self.groupBox = QtGui.QGroupBox(Dialog)
        self.groupBox.setGeometry(QtCore.QRect(10, 10, 573, 360))
        self.groupBox.setObjectName("groupBox")
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.groupBox)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtGui.QLabel(self.groupBox)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        spacerItem = QtGui.QSpacerItem(198, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.label_2 = QtGui.QLabel(self.groupBox)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout.addWidget(self.label_2)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.verticalLayout_2.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.listWidget = QtGui.QListWidget(self.groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(2)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.listWidget.sizePolicy().hasHeightForWidth())
        self.listWidget.setSizePolicy(sizePolicy)
        self.listWidget.setObjectName("listWidget")
        self.horizontalLayout_2.addWidget(self.listWidget)
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        spacerItem2 = QtGui.QSpacerItem(20, 78, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(spacerItem2)
        self.pushButton = QtGui.QPushButton(self.groupBox)
        self.pushButton.setObjectName("pushButton")
        self.verticalLayout.addWidget(self.pushButton)
        spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(spacerItem3)
        self.pushButton_2 = QtGui.QPushButton(self.groupBox)
        self.pushButton_2.setObjectName("pushButton_2")
        self.verticalLayout.addWidget(self.pushButton_2)
        spacerItem4 = QtGui.QSpacerItem(20, 108, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(spacerItem4)
        self.horizontalLayout_2.addLayout(self.verticalLayout)
        self.tabWidget = QtGui.QTabWidget(self.groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(3)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth())
        self.tabWidget.setSizePolicy(sizePolicy)
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtGui.QWidget()
        self.tab.setObjectName("tab")
        self.listWidget_2 = QtGui.QListWidget(self.tab)
        self.listWidget_2.setGeometry(QtCore.QRect(0, 0, 271, 273))
        self.listWidget_2.setObjectName("listWidget_2")
        self.tabWidget.addTab(self.tab, "")
        self.tab_7 = QtGui.QWidget()
        self.tab_7.setObjectName("tab_7")
        self.listWidget_3 = QtGui.QListWidget(self.tab_7)
        self.listWidget_3.setGeometry(QtCore.QRect(0, 0, 271, 273))
        self.listWidget_3.setObjectName("listWidget_3")
        self.tabWidget.addTab(self.tab_7, "")
        self.tab_6 = QtGui.QWidget()
        self.tab_6.setObjectName("tab_6")
        self.listWidget_4 = QtGui.QListWidget(self.tab_6)
        self.listWidget_4.setGeometry(QtCore.QRect(0, 0, 271, 273))
        self.listWidget_4.setObjectName("listWidget_4")
        self.tabWidget.addTab(self.tab_6, "")
        self.tab_2 = QtGui.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.listWidget_5 = QtGui.QListWidget(self.tab_2)
        self.listWidget_5.setGeometry(QtCore.QRect(0, 0, 271, 273))
        self.listWidget_5.setObjectName("listWidget_5")
        self.tabWidget.addTab(self.tab_2, "")
        self.tab_3 = QtGui.QWidget()
        self.tab_3.setObjectName("tab_3")
        self.listWidget_6 = QtGui.QListWidget(self.tab_3)
        self.listWidget_6.setGeometry(QtCore.QRect(0, 0, 271, 273))
        self.listWidget_6.setObjectName("listWidget_6")
        self.tabWidget.addTab(self.tab_3, "")
        self.tab_4 = QtGui.QWidget()
        self.tab_4.setObjectName("tab_4")
        self.listWidget_7 = QtGui.QListWidget(self.tab_4)
        self.listWidget_7.setGeometry(QtCore.QRect(0, 0, 271, 273))
        self.listWidget_7.setObjectName("listWidget_7")
        self.tabWidget.addTab(self.tab_4, "")
        self.tab_5 = QtGui.QWidget()
        self.tab_5.setObjectName("tab_5")
        self.listWidget_8 = QtGui.QListWidget(self.tab_5)
        self.listWidget_8.setGeometry(QtCore.QRect(0, 0, 271, 273))
        self.listWidget_8.setObjectName("listWidget_8")
        self.tabWidget.addTab(self.tab_5, "")
        self.horizontalLayout_2.addWidget(self.tabWidget)
        self.verticalLayout_2.addLayout(self.horizontalLayout_2)

        self.retranslateUi(Dialog)
        self.tabWidget.setCurrentIndex(6)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
    def addGroup(self):

        from PySide import QtCore,QtGui
        it = QtGui.QListWidgetItem("New Group")
        it.setFlags(it.flags() | QtCore.Qt.ItemIsEditable)
        self.form.groupsList.addItem(it)
Exemple #36
0
    def setupUi(self, ProjectWindow):
        ProjectWindow.setObjectName("ProjectWindow")
        ProjectWindow.resize(644, 422)
        self.centralwidget = QtGui.QWidget(ProjectWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.treeView = FileSystemTreeView(self.centralwidget)
        self.treeView.setObjectName("treeView")
        self.horizontalLayout.addWidget(self.treeView)
        ProjectWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(ProjectWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 644, 21))
        self.menubar.setObjectName("menubar")
        self.menuFile = QtGui.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        self.menuSettings = QtGui.QMenu(self.menubar)
        self.menuSettings.setObjectName("menuSettings")
        self.menuRecent_Files = QtGui.QMenu(self.menubar)
        self.menuRecent_Files.setObjectName("menuRecent_Files")
        self.menuActions = QtGui.QMenu(self.menubar)
        self.menuActions.setObjectName("menuActions")
        ProjectWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(ProjectWindow)
        self.statusbar.setObjectName("statusbar")
        ProjectWindow.setStatusBar(self.statusbar)
        self.toolBar = QtGui.QToolBar(ProjectWindow)
        self.toolBar.setObjectName("toolBar")
        ProjectWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar)
        self.actionNew = QtGui.QAction(ProjectWindow)
        self.actionNew.setObjectName("actionNew")
        self.actionOpen = QtGui.QAction(ProjectWindow)
        self.actionOpen.setObjectName("actionOpen")
        self.actionSave = QtGui.QAction(ProjectWindow)
        self.actionSave.setObjectName("actionSave")
        self.actionRemove = QtGui.QAction(ProjectWindow)
        self.actionRemove.setObjectName("actionRemove")
        self.actionPreferences = QtGui.QAction(ProjectWindow)
        self.actionPreferences.setObjectName("actionPreferences")
        self.actionMergePurge = QtGui.QAction(ProjectWindow)
        self.actionMergePurge.setObjectName("actionMergePurge")
        self.actionRename = QtGui.QAction(ProjectWindow)
        self.actionRename.setObjectName("actionRename")
        self.actionZip = QtGui.QAction(ProjectWindow)
        self.actionZip.setObjectName("actionZip")
        self.actionViewCloud = QtGui.QAction(ProjectWindow)
        self.actionViewCloud.setObjectName("actionViewCloud")
        self.actionAddFolder = QtGui.QAction(ProjectWindow)
        self.actionAddFolder.setObjectName("actionAddFolder")
        self.actionUnzip = QtGui.QAction(ProjectWindow)
        self.actionUnzip.setObjectName("actionUnzip")
        self.menuFile.addAction(self.actionNew)
        self.menuFile.addAction(self.actionOpen)
        self.menuFile.addAction(self.actionSave)
        self.menuFile.addAction(self.actionRemove)
        self.menuSettings.addAction(self.actionPreferences)
        self.menuActions.addAction(self.actionMergePurge)
        self.menuActions.addAction(self.actionAddFolder)
        self.menuActions.addAction(self.actionRename)
        self.menuActions.addAction(self.actionViewCloud)
        self.menuActions.addAction(self.actionUnzip)
        self.menuActions.addAction(self.actionZip)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuRecent_Files.menuAction())
        self.menubar.addAction(self.menuActions.menuAction())
        self.menubar.addAction(self.menuSettings.menuAction())
        self.toolBar.addSeparator()

        self.retranslateUi(ProjectWindow)
        QtCore.QMetaObject.connectSlotsByName(ProjectWindow)
Exemple #37
0
 def buatTeks(self):
     self.indikator = QtGui.QLabel(''' mn-belajarpython.blogspot.co.id ''')
     self.waktuPutar = QtGui.QLabel("00:00")
     self.waktuTotal = QtGui.QLabel("00:00")
     self.nilaiVolume = QtGui.QLabel('100%')
Exemple #38
0
    def setupUi(self, LoginForm):
        LoginForm.setObjectName("LoginForm")
        LoginForm.resize(460, 185)
        LoginForm.setBaseSize(QtCore.QSize(0, 0))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/icons/icons/app_icon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        LoginForm.setWindowIcon(icon)
        LoginForm.setSizeGripEnabled(False)
        self.verticalLayout = QtGui.QVBoxLayout(LoginForm)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.connectIcon = QtGui.QLabel(LoginForm)
        self.connectIcon.setText("")
        self.connectIcon.setPixmap(QtGui.QPixmap(":/icons/icons/conect22.png"))
        self.connectIcon.setObjectName("connectIcon")
        self.horizontalLayout_2.addWidget(self.connectIcon)
        self.headerLbl = QtGui.QLabel(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.headerLbl.sizePolicy().hasHeightForWidth())
        self.headerLbl.setSizePolicy(sizePolicy)
        self.headerLbl.setObjectName("headerLbl")
        self.horizontalLayout_2.addWidget(self.headerLbl)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.line = QtGui.QFrame(LoginForm)
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout.addWidget(self.line)
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.serverLbl = QtGui.QLabel(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.serverLbl.sizePolicy().hasHeightForWidth())
        self.serverLbl.setSizePolicy(sizePolicy)
        self.serverLbl.setObjectName("serverLbl")
        self.gridLayout.addWidget(self.serverLbl, 0, 0, 1, 1)
        self.serverEdit = QtGui.QLineEdit(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.serverEdit.sizePolicy().hasHeightForWidth())
        self.serverEdit.setSizePolicy(sizePolicy)
        self.serverEdit.setObjectName("serverEdit")
        self.gridLayout.addWidget(self.serverEdit, 0, 1, 1, 1)
        self.usernameLbl = QtGui.QLabel(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.usernameLbl.sizePolicy().hasHeightForWidth())
        self.usernameLbl.setSizePolicy(sizePolicy)
        self.usernameLbl.setObjectName("usernameLbl")
        self.gridLayout.addWidget(self.usernameLbl, 1, 0, 1, 1)
        self.usernameEdit = QtGui.QLineEdit(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.usernameEdit.sizePolicy().hasHeightForWidth())
        self.usernameEdit.setSizePolicy(sizePolicy)
        self.usernameEdit.setPlaceholderText("")
        self.usernameEdit.setObjectName("usernameEdit")
        self.gridLayout.addWidget(self.usernameEdit, 1, 1, 1, 1)
        self.passwordLbl = QtGui.QLabel(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.passwordLbl.sizePolicy().hasHeightForWidth())
        self.passwordLbl.setSizePolicy(sizePolicy)
        self.passwordLbl.setObjectName("passwordLbl")
        self.gridLayout.addWidget(self.passwordLbl, 2, 0, 1, 1)
        self.passwordEdit = QtGui.QLineEdit(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.passwordEdit.sizePolicy().hasHeightForWidth())
        self.passwordEdit.setSizePolicy(sizePolicy)
        self.passwordEdit.setEchoMode(QtGui.QLineEdit.Password)
        self.passwordEdit.setPlaceholderText("")
        self.passwordEdit.setObjectName("passwordEdit")
        self.gridLayout.addWidget(self.passwordEdit, 2, 1, 1, 1)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.infoIcon = QtGui.QLabel(LoginForm)
        self.infoIcon.setEnabled(True)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.infoIcon.sizePolicy().hasHeightForWidth())
        self.infoIcon.setSizePolicy(sizePolicy)
        self.infoIcon.setMinimumSize(QtCore.QSize(0, 0))
        self.infoIcon.setMaximumSize(QtCore.QSize(32, 32))
        self.infoIcon.setBaseSize(QtCore.QSize(0, 0))
        self.infoIcon.setText("")
        self.infoIcon.setPixmap(QtGui.QPixmap(":/icons/icons/info16.png"))
        self.infoIcon.setObjectName("infoIcon")
        self.horizontalLayout.addWidget(self.infoIcon)
        self.warningLbl = QtGui.QLabel(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.warningLbl.sizePolicy().hasHeightForWidth())
        self.warningLbl.setSizePolicy(sizePolicy)
        self.warningLbl.setObjectName("warningLbl")
        self.horizontalLayout.addWidget(self.warningLbl)
        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.horizontalLayout.addItem(spacerItem)
        self.gridLayout.addLayout(self.horizontalLayout, 3, 1, 1, 1)
        self.buttonBox = QtGui.QDialogButtonBox(LoginForm)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.buttonBox.sizePolicy().hasHeightForWidth())
        self.buttonBox.setSizePolicy(sizePolicy)
        self.buttonBox.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 4, 0, 1, 2)
        self.verticalLayout.addLayout(self.gridLayout)

        self.retranslateUi(LoginForm)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), LoginForm.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), LoginForm.reject)
        QtCore.QMetaObject.connectSlotsByName(LoginForm)
Exemple #39
0
 def create_layouts(self):
     main_layout = QtGui.QVBoxLayout(self)
     main_layout.setContentsMargins(0, 0, 0, 0)
     main_layout.addWidget(self.ui)
Exemple #40
0
 def OpenPreferences(self):
     self.Pre = Ui_Preferences()
     self.Dialog = QtGui.QDialog()
     self.Pre.setupUi(self.Dialog, self)
     self.Dialog.exec_()
Exemple #41
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(618, 654)
        self.Frame = QtGui.QFrame()
        self.Layout = QtGui.QHBoxLayout()
        self.gbxInfo = QtGui.QGroupBox()
        self.gbxInfo.setTitle('Information')
        self.Info = InfoPanel()
        self.InfoLayout = QtGui.QHBoxLayout()
        self.InfoLayout.addWidget(self.Info)
        self.gbxInfo.setLayout(self.InfoLayout)
        self.Wdg = QtGui.QVBoxLayout()
        self.Frame.setLayout(self.Layout)
        self.tabWidget = QtGui.QTabWidget()
        self.tabWidget.setGeometry(QtCore.QRect(0, 0, 621, 611))
        self.tabAnalyze = QtGui.QWidget()
        self.lblTarget = QtGui.QLabel(self.tabAnalyze)
        self.lblTarget.setGeometry(QtCore.QRect(10, 20, 64, 21))
        self.edtTarget = QtGui.QLineEdit(self.tabAnalyze)
        self.edtTarget.setGeometry(QtCore.QRect(90, 10, 441, 33))
        self.btnAnalyze = QtGui.QPushButton(self.tabAnalyze)
        self.btnAnalyze.setGeometry(QtCore.QRect(540, 10, 71, 31))
        self.lblMethod = QtGui.QLabel(self.tabAnalyze)
        self.lblMethod.setGeometry(QtCore.QRect(10, 60, 64, 21))
        self.cbxMethod = QtGui.QComboBox(self.tabAnalyze)
        self.cbxMethod.setGeometry(QtCore.QRect(90, 60, 76, 29))
        self.cbxMethod.addItem("")
        self.cbxMethod.addItem("")
        self.lblPostData = QtGui.QLabel(self.tabAnalyze)
        self.lblPostData.setGeometry(QtCore.QRect(10, 100, 71, 21))
        self.lblPostData.setVisible(False)
        self.edtPostData = QtGui.QLineEdit(self.tabAnalyze)
        self.edtPostData.setGeometry(QtCore.QRect(90, 100, 441, 33))
        self.edtPostData.setVisible(False)
        self.tabWidget.addTab(self.tabAnalyze, "")
        self.tabRawData = QtGui.QWidget()
        self.tabWidget.addTab(self.tabRawData, "")
        self.tabData = tabData(self)
        self.tabWidget.addTab(self.tabData, 'Data')
        self.RawData = Raw_Data(self)
        self.RawView = QtGui.QPlainTextEdit()
        self.RawView.setReadOnly(True)
        self.RDLayout = QtGui.QHBoxLayout(self.tabRawData)
        self.RDLayout.addWidget(self.RawData)
        self.RDLayout.addWidget(self.RawView)
        MainWindow.setCentralWidget(self.Frame)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 618, 27))
        self.menubar.setObjectName("menubar")
        self.menuTyrant = QtGui.QMenu(self.menubar)
        self.menuTyrant.setObjectName("menuFile")
        self.menuHelp = QtGui.QMenu(self.menubar)
        self.menuHelp.setObjectName("menuHelp")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionSql_Map_Hlelp = QtGui.QAction(MainWindow)
        self.actionOnline_Help = QtGui.QAction(MainWindow)
        self.actionLicense = QtGui.QAction(MainWindow)
        self.actionAbout = QtGui.QAction(MainWindow)
        self.actionExit = QtGui.QAction(MainWindow)
        self.actionPreferences = QtGui.QAction(MainWindow)
        self.actionPreferences.setText('Preferences')
        self.menuTyrant.addSeparator()
        self.menuTyrant.addAction(self.actionPreferences)
        self.menuTyrant.addSeparator()
        self.menuTyrant.addAction(self.actionExit)
        self.menuHelp.addAction(self.actionSql_Map_Hlelp)
        self.menuHelp.addAction(self.actionOnline_Help)
        self.menuHelp.addSeparator()
        self.menuHelp.addAction(self.actionLicense)
        self.menuHelp.addAction(self.actionAbout)
        self.menubar.addAction(self.menuTyrant.menuAction())
        self.menubar.addAction(self.menuHelp.menuAction())
        self.Wdg.addWidget(self.tabWidget)
        self.Wdg.addWidget(self.gbxInfo)
        self.Wdg.setStretchFactor(self.tabWidget, 10)
        self.Wdg.setStretchFactor(self.gbxInfo, 5)
        self.Layout.addLayout(self.Wdg)
        self.RawData.hide()
        Test = TestPython()
        Working = Test.TestVersion()
        Test2 = TestPython(1)
        Working = Test2.TestVersion()
        if not Working:
            Msg = QtGui.QMessageBox()
            Msg.information(
                self, 'Python',
                'Tyrant failed to find Python >=2.5.* and <=2.7.* \n Goto' +
                ' preferences!!')

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        #to hide or show post data
        QtCore.QObject.connect(self.cbxMethod,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.ShowHidePostData)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
        self.actionPreferences.triggered.connect(self.OpenPreferences)
        self.SQLMap = SqlMap(self)
        self.btnAnalyze.clicked.connect(self.Analyze)
        self.actionSql_Map_Hlelp.triggered.connect(self.SqlMapHelp)
        self.actionAbout.triggered.connect(self.About)
        self.actionLicense.triggered.connect(self.License)
        self.actionOnline_Help.triggered.connect(self.TyrantHelp)
        self.actionExit.triggered.connect(self.close)
Exemple #42
0
    def taskbox(self):
        "sets up a taskbox widget"
        w = QtGui.QWidget()
        ui = FreeCADGui.UiLoader()
        w.setWindowTitle(translate("Arch", "Wall options").decode("utf8"))
        grid = QtGui.QGridLayout(w)

        label5 = QtGui.QLabel(translate("Arch", "Length").decode("utf8"))
        self.Length = ui.createWidget("Gui::InputField")
        self.Length.setText("0.00 mm")
        grid.addWidget(label5, 0, 0, 1, 1)
        grid.addWidget(self.Length, 0, 1, 1, 1)

        label1 = QtGui.QLabel(translate("Arch", "Width").decode("utf8"))
        value1 = ui.createWidget("Gui::InputField")
        value1.setText(
            FreeCAD.Units.Quantity(self.Width,
                                   FreeCAD.Units.Length).UserString)
        grid.addWidget(label1, 1, 0, 1, 1)
        grid.addWidget(value1, 1, 1, 1, 1)

        label2 = QtGui.QLabel(translate("Arch", "Height").decode("utf8"))
        value2 = ui.createWidget("Gui::InputField")
        value2.setText(
            FreeCAD.Units.Quantity(self.Height,
                                   FreeCAD.Units.Length).UserString)
        grid.addWidget(label2, 2, 0, 1, 1)
        grid.addWidget(value2, 2, 1, 1, 1)

        label3 = QtGui.QLabel(translate("Arch", "Alignment").decode("utf8"))
        value3 = QtGui.QComboBox()
        items = ["Center", "Left", "Right"]
        value3.addItems(items)
        value3.setCurrentIndex(items.index(self.Align))
        grid.addWidget(label3, 3, 0, 1, 1)
        grid.addWidget(value3, 3, 1, 1, 1)

        label4 = QtGui.QLabel(translate("Arch", "Con&tinue").decode("utf8"))
        value4 = QtGui.QCheckBox()
        value4.setObjectName("ContinueCmd")
        value4.setLayoutDirection(QtCore.Qt.RightToLeft)
        label4.setBuddy(value4)
        if hasattr(FreeCADGui, "draftToolBar"):
            value4.setChecked(FreeCADGui.draftToolBar.continueMode)
            self.continueCmd = FreeCADGui.draftToolBar.continueMode
        grid.addWidget(label4, 4, 0, 1, 1)
        grid.addWidget(value4, 4, 1, 1, 1)

        QtCore.QObject.connect(self.Length,
                               QtCore.SIGNAL("valueChanged(double)"),
                               self.setLength)
        QtCore.QObject.connect(value1, QtCore.SIGNAL("valueChanged(double)"),
                               self.setWidth)
        QtCore.QObject.connect(value2, QtCore.SIGNAL("valueChanged(double)"),
                               self.setHeight)
        QtCore.QObject.connect(value3,
                               QtCore.SIGNAL("currentIndexChanged(int)"),
                               self.setAlign)
        QtCore.QObject.connect(value4, QtCore.SIGNAL("stateChanged(int)"),
                               self.setContinue)
        QtCore.QObject.connect(self.Length, QtCore.SIGNAL("returnPressed()"),
                               value1.setFocus)
        QtCore.QObject.connect(self.Length, QtCore.SIGNAL("returnPressed()"),
                               value1.selectAll)
        QtCore.QObject.connect(value1, QtCore.SIGNAL("returnPressed()"),
                               value2.setFocus)
        QtCore.QObject.connect(value1, QtCore.SIGNAL("returnPressed()"),
                               value2.selectAll)
        QtCore.QObject.connect(value2, QtCore.SIGNAL("returnPressed()"),
                               self.createFromGUI)
        return w
Exemple #43
0
    def __init__(self):
        super(MainWin, self).__init__()

        logger.info("* > APP: initializing ...")

        # set the application name and the version
        self.name = ssm_name
        self.version = ssm_version
        self.setWindowTitle('%s v.%s' % (self.name, self.version))
        # noinspection PyArgumentList
        _app = QtCore.QCoreApplication.instance()
        _app.setApplicationName('%s' % self.name)
        _app.setOrganizationName("HydrOffice")
        _app.setOrganizationDomain("hydroffice.org")

        # set the minimum and the initial size
        self.setMinimumSize(640, 480)
        self.resize(920, 600)

        # set icons
        icon_info = QtCore.QFileInfo(os.path.join(self.media, 'favicon.png'))
        self.setWindowIcon(QtGui.QIcon(icon_info.absoluteFilePath()))
        if (sys.platform == 'win32') or (os.name is "nt"):  # is_windows()
            try:
                # This is needed to display the app icon on the taskbar on Windows 7
                import ctypes
                app_id = '%s v.%s' % (self.name, self.version)
                ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
            except AttributeError as e:
                logger.debug("Unable to change app icon: %s" % e)

        # set palette/stylesheet
        style_info = QtCore.QFileInfo(os.path.join(self.here, 'styles', 'main.stylesheet'))
        style_content = open(style_info.filePath()).read()
        self.setStyleSheet(style_content)

        # check if setup db exists; if yes, ask to copy
        has_setup = SoundSpeedLibrary.setup_exists()
        logger.info("setup exists: %s" % has_setup)
        if not has_setup:
            other_setups = SoundSpeedLibrary.list_other_setups()
            if len(other_setups) != 0:
                logger.debug("other existing setups: %d" % len(other_setups))
                sel, ok = QtGui.QInputDialog.getItem(self, 'Do you want to copy an existing setup?',
                                                     'Select one (or click on Cancel to create a new one):',
                                                     other_setups, 0, False)
                if ok:
                    SoundSpeedLibrary.copy_setup(input_setup=sel)

        # create the project
        self.lib = SoundSpeedLibrary(callbacks=QtCallbacks(parent=self), progress=QtProgress(parent=self))
        logger.debug("dependencies:\n%s" % info_libs())
        self.check_woa09()
        self.check_woa13()
        # self.check_rtofs()  # no need to wait for the download at the beginning
        self.check_sis()
        self.check_sippican()
        self.check_mvp()

        # init default settings
        settings = QtCore.QSettings()
        export_folder = settings.value("export_folder")
        if (export_folder is None) or (not os.path.exists(export_folder)):
            settings.setValue("export_folder", self.lib.data_folder)
        import_folder = settings.value("import_folder")
        if (import_folder is None) or (not os.path.exists(import_folder)):
            settings.setValue("import_folder", self.lib.data_folder)

        # menu

        self.menu = self.menuBar()
        self.file_menu = self.menu.addMenu("File")
        self.edit_menu = self.menu.addMenu("Process")
        self.database_menu = self.menu.addMenu("Database")
        self.monitor_menu = self.menu.addMenu("Monitor")
        self.server_menu = self.menu.addMenu("Server")
        self.setup_menu = self.menu.addMenu("Setup")
        self.help_menu = self.menu.addMenu("Help")

        # make tabs
        self.tabs = QtGui.QTabWidget()
        self.setCentralWidget(self.tabs)
        self.tabs.setIconSize(QtCore.QSize(42, 42))
        self.tabs.blockSignals(True)  # during the initialization
        self.tabs.currentChanged.connect(self.onChange)  # changed!
        # editor
        self.tab_editor = Editor(lib=self.lib, main_win=self)
        self.idx_editor = self.tabs.insertTab(0, self.tab_editor,
                                              QtGui.QIcon(os.path.join(self.here, 'media', 'editor.png')), "")
        self.tabs.setTabToolTip(self.idx_editor, "Editor")
        # database
        self.tab_database = Database(lib=self.lib, main_win=self)
        self.idx_database = self.tabs.insertTab(1, self.tab_database,
                                                QtGui.QIcon(os.path.join(self.here, 'media', 'database.png')), "")
        self.tabs.setTabToolTip(self.idx_database, "Database")
        # seacat
        # self.tab_seacat = Seacat(lib=self.lib, main_win=self)
        # self.idx_seacat = self.tabs.insertTab(2, self.tab_seacat,
        #                                       QtGui.QIcon(os.path.join(self.here, 'media', 'seacat.png')), "")
        # self.tabs.setTabToolTip(self.idx_seacat, "SeaCAT")
        # if not self.lib.setup.noaa_tools:
        #     self.tab_seacat.setDisabled(True)
        # survey data monitor
        self.has_sdm_support = True
        try:  # try.. except to make SSM working also without SDM
            from hyo.surveydatamonitor.app.widgets.monitor import SurveyDataMonitor
            self.tab_monitor = SurveyDataMonitor(lib=self.lib, main_win=self)
            self.idx_monitor = self.tabs.insertTab(3, self.tab_monitor,
                                                   QtGui.QIcon(os.path.join(self.here, 'media', 'surveydatamonitor.png')), "")
            self.tabs.setTabToolTip(self.idx_monitor, "Survey Data Monitor")
            logger.info("Support for Survey Monitor: ON")
        except Exception as e:
            traceback.print_exc()
            self.has_sdm_support = False
            logger.info("Support for Survey Monitor: OFF(%s)" % e)
        # server
        self.tab_server = Server(lib=self.lib, main_win=self)
        self.idx_server = self.tabs.insertTab(4, self.tab_server,
                                              QtGui.QIcon(os.path.join(self.here, 'media', 'server.png')), "")
        self.tabs.setTabToolTip(self.idx_server, "Synthetic Profile Server")
        # refraction
        self.tab_refraction = Refraction(lib=self.lib, main_win=self)
        # idx = self.tabs.insertTab(5, self.tab_refraction,
        #                           QtGui.QIcon(os.path.join(self.here, 'media', 'refraction.png')), "")
        # self.tabs.setTabToolTip(idx, "Refraction Monitor")
        # setup
        self.tab_setup = Settings(lib=self.lib, main_win=self)
        self.idx_setup = self.tabs.insertTab(6, self.tab_setup,
                                             QtGui.QIcon(os.path.join(self.here, 'media', 'settings.png')), "")
        self.tabs.setTabToolTip(self.idx_setup, "Setup")
        # info
        self.tab_info = Info(main_win=self, default_url=web_url())
        self.idx_info = self.tabs.insertTab(6, self.tab_info,
                                            QtGui.QIcon(os.path.join(self.here, 'media', 'info.png')), "")
        self.tabs.setTabToolTip(self.idx_info, "Info")

        self.statusBar().setStyleSheet("QStatusBar{color:rgba(0,0,0,128);font-size: 8pt;}")
        self.status_bar_normal_style = self.statusBar().styleSheet()
        self.statusBar().showMessage("%s" % ssm_version, 2000)
        self.releaseInfo = QtGui.QLabel()
        self.statusBar().addPermanentWidget(self.releaseInfo)
        self.releaseInfo.setStyleSheet("QLabel{color:rgba(0,0,0,128);font-size: 8pt;}")
        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.update_gui)
        timer.start(1500)
        self.timer_execs = 0

        self.data_cleared()
        self.tabs.blockSignals(False)

        logger.info("* > APP: initialized!")
    def setupUi(self, MeshGeneratorWidget):
        MeshGeneratorWidget.setObjectName("MeshGeneratorWidget")
        MeshGeneratorWidget.resize(927, 829)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            MeshGeneratorWidget.sizePolicy().hasHeightForWidth())
        MeshGeneratorWidget.setSizePolicy(sizePolicy)
        self.gridLayout_3 = QtGui.QGridLayout(MeshGeneratorWidget)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.dockWidget = QtGui.QDockWidget(MeshGeneratorWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.dockWidget.sizePolicy().hasHeightForWidth())
        self.dockWidget.setSizePolicy(sizePolicy)
        self.dockWidget.setMinimumSize(QtCore.QSize(492, 557))
        self.dockWidget.setFeatures(QtGui.QDockWidget.DockWidgetFloatable
                                    | QtGui.QDockWidget.DockWidgetMovable)
        self.dockWidget.setAllowedAreas(QtCore.Qt.AllDockWidgetAreas)
        self.dockWidget.setObjectName("dockWidget")
        self.dockWidgetContents = QtGui.QWidget()
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.dockWidgetContents.sizePolicy().hasHeightForWidth())
        self.dockWidgetContents.setSizePolicy(sizePolicy)
        self.dockWidgetContents.setObjectName("dockWidgetContents")
        self.verticalLayout = QtGui.QVBoxLayout(self.dockWidgetContents)
        self.verticalLayout.setObjectName("verticalLayout")
        self.scrollArea = QtGui.QScrollArea(self.dockWidgetContents)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.scrollArea.sizePolicy().hasHeightForWidth())
        self.scrollArea.setSizePolicy(sizePolicy)
        self.scrollArea.setMinimumSize(QtCore.QSize(0, 0))
        self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setObjectName("scrollArea")
        self.scrollAreaWidgetContents_2 = QtGui.QWidget()
        self.scrollAreaWidgetContents_2.setGeometry(
            QtCore.QRect(0, 0, 470, 417))
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.scrollAreaWidgetContents_2.sizePolicy().hasHeightForWidth())
        self.scrollAreaWidgetContents_2.setSizePolicy(sizePolicy)
        self.scrollAreaWidgetContents_2.setObjectName(
            "scrollAreaWidgetContents_2")
        self.verticalLayout_2 = QtGui.QVBoxLayout(
            self.scrollAreaWidgetContents_2)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.verticalLayout_3 = QtGui.QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.time_groupBox = QtGui.QGroupBox(self.scrollAreaWidgetContents_2)
        self.time_groupBox.setObjectName("time_groupBox")
        self.gridLayout_4 = QtGui.QGridLayout(self.time_groupBox)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.timeValue_doubleSpinBox = QtGui.QDoubleSpinBox(self.time_groupBox)
        self.timeValue_doubleSpinBox.setMaximum(12000.0)
        self.timeValue_doubleSpinBox.setObjectName("timeValue_doubleSpinBox")
        self.gridLayout_4.addWidget(self.timeValue_doubleSpinBox, 0, 1, 1, 1)
        self.timeLoop_checkBox = QtGui.QCheckBox(self.time_groupBox)
        self.timeLoop_checkBox.setObjectName("timeLoop_checkBox")
        self.gridLayout_4.addWidget(self.timeLoop_checkBox, 1, 2, 1, 1)
        self.timeValue_label = QtGui.QLabel(self.time_groupBox)
        self.timeValue_label.setObjectName("timeValue_label")
        self.gridLayout_4.addWidget(self.timeValue_label, 0, 0, 1, 1)
        self.timePlayStop_pushButton = QtGui.QPushButton(self.time_groupBox)
        self.timePlayStop_pushButton.setObjectName("timePlayStop_pushButton")
        self.gridLayout_4.addWidget(self.timePlayStop_pushButton, 1, 1, 1, 1)
        self.verticalLayout_3.addWidget(self.time_groupBox)
        self.video_groupBox = QtGui.QGroupBox(self.scrollAreaWidgetContents_2)
        self.video_groupBox.setObjectName("video_groupBox")
        self.gridLayout_2 = QtGui.QGridLayout(self.video_groupBox)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.framesPerSecond_spinBox = QtGui.QSpinBox(self.video_groupBox)
        self.framesPerSecond_spinBox.setMinimum(1)
        self.framesPerSecond_spinBox.setProperty("value", 25)
        self.framesPerSecond_spinBox.setObjectName("framesPerSecond_spinBox")
        self.gridLayout_2.addWidget(self.framesPerSecond_spinBox, 1, 1, 1, 1)
        self.frameIndex_label = QtGui.QLabel(self.video_groupBox)
        self.frameIndex_label.setObjectName("frameIndex_label")
        self.gridLayout_2.addWidget(self.frameIndex_label, 0, 0, 1, 1)
        self.frameIndex_spinBox = QtGui.QSpinBox(self.video_groupBox)
        self.frameIndex_spinBox.setMinimum(1)
        self.frameIndex_spinBox.setMaximum(10000)
        self.frameIndex_spinBox.setObjectName("frameIndex_spinBox")
        self.gridLayout_2.addWidget(self.frameIndex_spinBox, 0, 1, 1, 1)
        self.framesPerSecond_label = QtGui.QLabel(self.video_groupBox)
        self.framesPerSecond_label.setObjectName("framesPerSecond_label")
        self.gridLayout_2.addWidget(self.framesPerSecond_label, 1, 0, 1, 1)
        self.numFrames_frame = QtGui.QFrame(self.video_groupBox)
        self.numFrames_frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.numFrames_frame.setFrameShadow(QtGui.QFrame.Raised)
        self.numFrames_frame.setObjectName("numFrames_frame")
        self.horizontalLayout_4 = QtGui.QHBoxLayout(self.numFrames_frame)
        self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.numFrames_label = QtGui.QLabel(self.numFrames_frame)
        self.numFrames_label.setObjectName("numFrames_label")
        self.horizontalLayout_4.addWidget(self.numFrames_label)
        self.numFramesValue_label = QtGui.QLabel(self.numFrames_frame)
        self.numFramesValue_label.setObjectName("numFramesValue_label")
        self.horizontalLayout_4.addWidget(self.numFramesValue_label)
        self.gridLayout_2.addWidget(self.numFrames_frame, 0, 2, 1, 1)
        self.verticalLayout_3.addWidget(self.video_groupBox)
        self.verticalLayout_2.addLayout(self.verticalLayout_3)
        self.scrollArea.setWidget(self.scrollAreaWidgetContents_2)
        self.verticalLayout.addWidget(self.scrollArea)
        self.blackfynn_groupBox = QtGui.QGroupBox(self.dockWidgetContents)
        self.blackfynn_groupBox.setObjectName("blackfynn_groupBox")
        self.gridLayout_5 = QtGui.QGridLayout(self.blackfynn_groupBox)
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.blackfynnDatasets_label = QtGui.QLabel(self.blackfynn_groupBox)
        self.blackfynnDatasets_label.setObjectName("blackfynnDatasets_label")
        self.gridLayout_5.addWidget(self.blackfynnDatasets_label, 1, 0, 1, 1)
        self.blackfynnDatasets_pushButton = QtGui.QPushButton(
            self.blackfynn_groupBox)
        self.blackfynnDatasets_pushButton.setText("")
        icon = QtGui.QIcon()
        icon.addPixmap(
            QtGui.QPixmap(":/meshgeneratorstep/images/download-icon-blue.png"),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.blackfynnDatasets_pushButton.setIcon(icon)
        self.blackfynnDatasets_pushButton.setObjectName(
            "blackfynnDatasets_pushButton")
        self.gridLayout_5.addWidget(self.blackfynnDatasets_pushButton, 1, 3, 1,
                                    1)
        self.downloadData_button = QtGui.QPushButton(self.blackfynn_groupBox)
        self.downloadData_button.setObjectName("downloadData_button")
        self.gridLayout_5.addWidget(self.downloadData_button, 5, 2, 1, 1)
        self.blackfynnDatasets_comboBox = QtGui.QComboBox(
            self.blackfynn_groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.blackfynnDatasets_comboBox.sizePolicy().hasHeightForWidth())
        self.blackfynnDatasets_comboBox.setSizePolicy(sizePolicy)
        self.blackfynnDatasets_comboBox.setObjectName(
            "blackfynnDatasets_comboBox")
        self.gridLayout_5.addWidget(self.blackfynnDatasets_comboBox, 1, 2, 1,
                                    1)
        self.pushButton = QtGui.QPushButton(self.blackfynn_groupBox)
        self.pushButton.setObjectName("pushButton")
        self.gridLayout_5.addWidget(self.pushButton, 6, 2, 1, 1)
        self.blackfynnTimeSeries_pushButton = QtGui.QPushButton(
            self.blackfynn_groupBox)
        self.blackfynnTimeSeries_pushButton.setText("")
        self.blackfynnTimeSeries_pushButton.setIcon(icon)
        self.blackfynnTimeSeries_pushButton.setObjectName(
            "blackfynnTimeSeries_pushButton")
        self.gridLayout_5.addWidget(self.blackfynnTimeSeries_pushButton, 4, 3,
                                    1, 1)
        self.blackfynnTimeSeries_comboBox = QtGui.QComboBox(
            self.blackfynn_groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.blackfynnTimeSeries_comboBox.sizePolicy().hasHeightForWidth())
        self.blackfynnTimeSeries_comboBox.setSizePolicy(sizePolicy)
        self.blackfynnTimeSeries_comboBox.setObjectName(
            "blackfynnTimeSeries_comboBox")
        self.gridLayout_5.addWidget(self.blackfynnTimeSeries_comboBox, 4, 2, 1,
                                    1)
        self.exportDirectory_lineEdit = QtGui.QLineEdit(
            self.blackfynn_groupBox)
        self.exportDirectory_lineEdit.setObjectName("exportDirectory_lineEdit")
        self.gridLayout_5.addWidget(self.exportDirectory_lineEdit, 8, 2, 1, 1)
        self.blackfynnTimeSeries_label = QtGui.QLabel(self.blackfynn_groupBox)
        self.blackfynnTimeSeries_label.setObjectName(
            "blackfynnTimeSeries_label")
        self.gridLayout_5.addWidget(self.blackfynnTimeSeries_label, 4, 0, 1, 1)
        self.blackfynnProfiles_groupBox = QtGui.QGroupBox(
            self.blackfynn_groupBox)
        self.blackfynnProfiles_groupBox.setObjectName(
            "blackfynnProfiles_groupBox")
        self.horizontalLayout_5 = QtGui.QHBoxLayout(
            self.blackfynnProfiles_groupBox)
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.profiles_comboBox = QtGui.QComboBox(
            self.blackfynnProfiles_groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(1)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.profiles_comboBox.sizePolicy().hasHeightForWidth())
        self.profiles_comboBox.setSizePolicy(sizePolicy)
        self.profiles_comboBox.setObjectName("profiles_comboBox")
        self.horizontalLayout_5.addWidget(self.profiles_comboBox)
        self.addProfile_pushButton = QtGui.QPushButton(
            self.blackfynnProfiles_groupBox)
        self.addProfile_pushButton.setText("")
        icon1 = QtGui.QIcon()
        icon1.addPixmap(
            QtGui.QPixmap(":/meshgeneratorstep/images/plus-icon-green-th.png"),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.addProfile_pushButton.setIcon(icon1)
        self.addProfile_pushButton.setObjectName("addProfile_pushButton")
        self.horizontalLayout_5.addWidget(self.addProfile_pushButton)
        self.gridLayout_5.addWidget(self.blackfynnProfiles_groupBox, 0, 0, 1,
                                    4)
        self.UploadToBlackfynn_button = QtGui.QPushButton(
            self.blackfynn_groupBox)
        self.UploadToBlackfynn_button.setObjectName("UploadToBlackfynn_button")
        self.gridLayout_5.addWidget(self.UploadToBlackfynn_button, 9, 2, 1, 1)
        self.verticalLayout.addWidget(self.blackfynn_groupBox)
        self.frame = QtGui.QFrame(self.dockWidgetContents)
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.frame)
        self.horizontalLayout_2.setContentsMargins(3, 3, 3, 3)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.viewAll_button = QtGui.QPushButton(self.frame)
        self.viewAll_button.setObjectName("viewAll_button")
        self.horizontalLayout_2.addWidget(self.viewAll_button)
        self.done_button = QtGui.QPushButton(self.frame)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.done_button.sizePolicy().hasHeightForWidth())
        self.done_button.setSizePolicy(sizePolicy)
        self.done_button.setObjectName("done_button")
        self.horizontalLayout_2.addWidget(self.done_button)
        self.verticalLayout.addWidget(self.frame)
        self.dockWidget.setWidget(self.dockWidgetContents)
        self.gridLayout_3.addWidget(self.dockWidget, 0, 0, 1, 1)
        self.sceneviewer_widget = AlignmentSceneviewerWidget(
            MeshGeneratorWidget)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(4)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.sceneviewer_widget.sizePolicy().hasHeightForWidth())
        self.sceneviewer_widget.setSizePolicy(sizePolicy)
        self.sceneviewer_widget.setObjectName("sceneviewer_widget")
        self.gridLayout_3.addWidget(self.sceneviewer_widget, 0, 1, 1, 1)

        self.retranslateUi(MeshGeneratorWidget)
        QtCore.QMetaObject.connectSlotsByName(MeshGeneratorWidget)
				self.keyb.linear.x  = self.pitch
				self.keyb.linear.y  = self.roll
				self.pubCommandP.publish(self.keyb)
				rospy.loginfo(self.roll)
				rospy.loginfo(self.pitch)
		                tiempo0=time()
                        veces-=1
		else:	
			self.pitch=0
                        self.roll=0
			self.keyb.linear.x  = self.pitch
			self.keyb.linear.y  = self.roll
			self.pubCommandP.publish(self.keyb)
			rospy.loginfo(self.roll)
			rospy.loginfo(self.pitch)
                       


if __name__=='__main__':
	import sys
	rospy.init_node('vuelo')
	app = QtGui.QApplication(sys.argv)

	display = Mainventana()
	display.show()
	status = app.exec_()

	# and only progresses to here once the application has been shutdown
	rospy.signal_shutdown('Great Flying!')
	sys.exit(status)
    def setupUi(self, PrimLegend):
        PrimLegend.setObjectName("PrimLegend")
        PrimLegend.resize(438, 131)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred,
                                       QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            PrimLegend.sizePolicy().hasHeightForWidth())
        PrimLegend.setSizePolicy(sizePolicy)
        self.primLegendLayoutContainer = QtGui.QVBoxLayout(PrimLegend)
        self.primLegendLayoutContainer.setObjectName(
            "primLegendLayoutContainer")
        self.primLegendLayout = QtGui.QGridLayout()
        self.primLegendLayout.setObjectName("primLegendLayout")
        self.primLegendColorHasArcs = QtGui.QGraphicsView(PrimLegend)
        self.primLegendColorHasArcs.setMaximumSize(QtCore.QSize(20, 15))
        self.primLegendColorHasArcs.setObjectName("primLegendColorHasArcs")
        self.primLegendLayout.addWidget(self.primLegendColorHasArcs, 0, 0, 1,
                                        1)
        self.primLegendLabelHasArcs = QtGui.QLabel(PrimLegend)
        font = QtGui.QFont()
        font.setWeight(50)
        font.setItalic(False)
        font.setBold(False)
        self.primLegendLabelHasArcs.setFont(font)
        self.primLegendLabelHasArcs.setObjectName("primLegendLabelHasArcs")
        self.primLegendLayout.addWidget(self.primLegendLabelHasArcs, 0, 1, 1,
                                        1)
        self.primLegendColorInstance = QtGui.QGraphicsView(PrimLegend)
        self.primLegendColorInstance.setMaximumSize(QtCore.QSize(20, 15))
        self.primLegendColorInstance.setObjectName("primLegendColorInstance")
        self.primLegendLayout.addWidget(self.primLegendColorInstance, 0, 2, 1,
                                        1)
        self.primLegendLabelInstance = QtGui.QLabel(PrimLegend)
        font = QtGui.QFont()
        font.setWeight(50)
        font.setItalic(False)
        font.setBold(False)
        self.primLegendLabelInstance.setFont(font)
        self.primLegendLabelInstance.setObjectName("primLegendLabelInstance")
        self.primLegendLayout.addWidget(self.primLegendLabelInstance, 0, 3, 1,
                                        1)
        self.primLegendColorMaster = QtGui.QGraphicsView(PrimLegend)
        self.primLegendColorMaster.setMaximumSize(QtCore.QSize(20, 15))
        self.primLegendColorMaster.setObjectName("primLegendColorMaster")
        self.primLegendLayout.addWidget(self.primLegendColorMaster, 0, 4, 1, 1)
        self.primLegendLabelMaster = QtGui.QLabel(PrimLegend)
        font = QtGui.QFont()
        font.setWeight(50)
        font.setItalic(False)
        font.setBold(False)
        self.primLegendLabelMaster.setFont(font)
        self.primLegendLabelMaster.setObjectName("primLegendLabelMaster")
        self.primLegendLayout.addWidget(self.primLegendLabelMaster, 0, 5, 1, 1)
        self.primLegendColorNormal = QtGui.QGraphicsView(PrimLegend)
        self.primLegendColorNormal.setMaximumSize(QtCore.QSize(20, 15))
        self.primLegendColorNormal.setObjectName("primLegendColorNormal")
        self.primLegendLayout.addWidget(self.primLegendColorNormal, 0, 6, 1, 1)
        self.primLegendLabelNormal = QtGui.QLabel(PrimLegend)
        font = QtGui.QFont()
        font.setWeight(50)
        font.setItalic(False)
        font.setBold(False)
        self.primLegendLabelNormal.setFont(font)
        self.primLegendLabelNormal.setObjectName("primLegendLabelNormal")
        self.primLegendLayout.addWidget(self.primLegendLabelNormal, 0, 7, 1, 1)
        self.primLegendLayoutContainer.addLayout(self.primLegendLayout)
        self.primLegendLabelContainer = QtGui.QVBoxLayout()
        self.primLegendLabelContainer.setObjectName("primLegendLabelContainer")
        self.primLegendLabelDimmed = QtGui.QLabel(PrimLegend)
        self.primLegendLabelDimmed.setObjectName("primLegendLabelDimmed")
        self.primLegendLabelContainer.addWidget(self.primLegendLabelDimmed)
        self.primLegendLabelFontsAbstract = QtGui.QLabel(PrimLegend)
        self.primLegendLabelFontsAbstract.setObjectName(
            "primLegendLabelFontsAbstract")
        self.primLegendLabelContainer.addWidget(
            self.primLegendLabelFontsAbstract)
        self.primLegendLabelFontsUndefined = QtGui.QLabel(PrimLegend)
        self.primLegendLabelFontsUndefined.setObjectName(
            "primLegendLabelFontsUndefined")
        self.primLegendLabelContainer.addWidget(
            self.primLegendLabelFontsUndefined)
        self.primLegendLabelFontsDefined = QtGui.QLabel(PrimLegend)
        self.primLegendLabelFontsDefined.setObjectName(
            "primLegendLabelFontsDefined")
        self.primLegendLabelContainer.addWidget(
            self.primLegendLabelFontsDefined)
        self.primLegendLayoutContainer.addLayout(self.primLegendLabelContainer)

        self.retranslateUi(PrimLegend)
        QtCore.QMetaObject.connectSlotsByName(PrimLegend)
Exemple #47
0
def main():
    app = QtGui.QApplication(sys.argv)
    ex = conductorUpdateStatusWidget(
        70564689)  #Using Bruce Wayne to Test Widget as standalone
    ex.show()
    sys.exit(app.exec_())
Exemple #48
0
    def updateListOfModes(self):
        '''needs suggestor to have been called, and assigned to self.last_sugr'''
        try:
            old_selfblock = self.block
            self.block = True
            list_widget = self.form.listOfModes
            list_widget.clear()
            sugr = self.last_sugr
            # always have the option to choose Deactivated mode
            valid_modes = ['Deactivated'] + sugr['allApplicableModes']

            # add valid modes
            for m in valid_modes:
                item = QtGui.QListWidgetItem()
                txt = self.attacher.getModeInfo(m)['UserFriendlyName']
                item.setText(txt)
                item.setData(self.KEYmode, m)
                item.setData(self.KEYon, True)
                if m == sugr['bestFitMode']:
                    f = item.font()
                    f.setBold(True)
                    item.setFont(f)
                list_widget.addItem(item)
                item.setSelected(self.attacher.Mode == m)
            # add potential modes
            for m in sugr['reachableModes'].keys():
                item = QtGui.QListWidgetItem()
                txt = self.attacher.getModeInfo(m)['UserFriendlyName']
                listlistrefs = sugr['reachableModes'][m]
                if len(listlistrefs) == 1:
                    listrefs_userfriendly = [
                        self.attacher.getRefTypeInfo(t)['UserFriendlyName']
                        for t in listlistrefs[0]
                    ]
                    txt = _translate(
                        'AttachmentEditor', "{mode} (add {morerefs})",
                        None).format(mode=txt,
                                     morerefs=u"+".join(listrefs_userfriendly))
                else:
                    txt = _translate('AttachmentEditor',
                                     "{mode} (add more references)",
                                     None).format(mode=txt)
                item.setText(txt)
                item.setData(self.KEYmode, m)
                item.setData(self.KEYon, True)
                if m == sugr['bestFitMode']:
                    f = item.font()
                    f.setBold(True)
                    item.setFont(f)

                #disable this item
                f = item.flags()
                f = f & ~(QtCore.Qt.ItemFlag.ItemIsEnabled
                          | QtCore.Qt.ItemFlag.ItemIsSelectable)
                item.setFlags(f)

                list_widget.addItem(item)

            # re-scan the list to fill in tooltips
            for item in list_widget.findItems('', QtCore.Qt.MatchContains):
                m = item.data(self.KEYmode)
                on = item.data(self.KEYon)

                mi = self.attacher.getModeInfo(m)
                cmb = []
                for refstr in mi['ReferenceCombinations']:
                    refstr_userfriendly = [
                        self.attacher.getRefTypeInfo(t)['UserFriendlyName']
                        for t in refstr
                    ]
                    cmb.append(u", ".join(refstr_userfriendly))

                tip = mi['BriefDocu']
                if (m != 'Deactivated'):
                    tip += u"\n\n"
                    tip += _translate('AttachmentEditor',
                                      "Reference combinations:",
                                      None) + u" \n\n".join(cmb)

                item.setToolTip(tip)

        finally:
            self.block = old_selfblock
Exemple #49
0
    def setupUi(self, ui_FISCAL_iSuprimento):
        ui_FISCAL_iSuprimento.setObjectName("ui_FISCAL_iSuprimento")
        ui_FISCAL_iSuprimento.resize(241, 105)
        self.verticalLayout_2 = QtGui.QVBoxLayout(ui_FISCAL_iSuprimento)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.labelValor = QtGui.QLabel(ui_FISCAL_iSuprimento)
        self.labelValor.setObjectName("labelValor")
        self.gridLayout.addWidget(self.labelValor, 0, 0, 1, 1)
        self.lineEditValor = QtGui.QLineEdit(ui_FISCAL_iSuprimento)
        self.lineEditValor.setMaximumSize(QtCore.QSize(80, 16777215))
        self.lineEditValor.setObjectName("lineEditValor")
        self.gridLayout.addWidget(self.lineEditValor, 0, 1, 1, 1)
        self.labelMensagem = QtGui.QLabel(ui_FISCAL_iSuprimento)
        self.labelMensagem.setObjectName("labelMensagem")
        self.gridLayout.addWidget(self.labelMensagem, 1, 0, 1, 1)
        self.lineEditMensagem = QtGui.QLineEdit(ui_FISCAL_iSuprimento)
        self.lineEditMensagem.setObjectName("lineEditMensagem")
        self.gridLayout.addWidget(self.lineEditMensagem, 1, 1, 1, 1)
        self.verticalLayout.addLayout(self.gridLayout)
        spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
                                       QtGui.QSizePolicy.Expanding)
        self.verticalLayout.addItem(spacerItem)
        self.verticalLayout_2.addLayout(self.verticalLayout)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.pushButtonEnviar = QtGui.QPushButton(ui_FISCAL_iSuprimento)
        self.pushButtonEnviar.setObjectName("pushButtonEnviar")
        self.horizontalLayout.addWidget(self.pushButtonEnviar)
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem2)
        self.pushButtonCancelar = QtGui.QPushButton(ui_FISCAL_iSuprimento)
        self.pushButtonCancelar.setObjectName("pushButtonCancelar")
        self.horizontalLayout.addWidget(self.pushButtonCancelar)
        spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem3)
        self.verticalLayout_2.addLayout(self.horizontalLayout)

        self.retranslateUi(ui_FISCAL_iSuprimento)
        QtCore.QMetaObject.connectSlotsByName(ui_FISCAL_iSuprimento)
Exemple #50
0
 def prepareLineEdit(self):
     # jednořádkové vstupní textové pole
     lineEdit = QtGui.QLineEdit(self)
     # naplnění textového pole textem
     lineEdit.setText(u"příliš žluťoučký kůň úpěl ďábelské ódy")
     return lineEdit
 def __init__(self, parent=None):
     super(Scene, self).__init__(parent)
     self.layers = []
     self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(96, 96, 96)))
Exemple #52
0
 def aboutDialog(self):
     msgBox = QtGui.QMessageBox()
     msgBox.setText("About:\n...\n...\n...")
     msgBox.setIcon(QtGui.QMessageBox.Information)
     msgBox.exec_()
Exemple #53
0
    def __init__(self,
                 obj_to_attach,
                 take_selection=False,
                 create_transaction=True,
                 callback_OK=None,
                 callback_Cancel=None,
                 callback_Apply=None):

        self.__define_attributes()

        self.create_transaction = create_transaction
        self.callback_OK = callback_OK
        self.callback_Cancel = callback_Cancel
        self.callback_Apply = callback_Apply

        self.obj = obj_to_attach
        if hasattr(obj_to_attach, 'Attacher'):
            self.attacher = obj_to_attach.Attacher
        elif hasattr(obj_to_attach, 'AttacherType'):
            self.attacher = Part.AttachEngine(obj_to_attach.AttacherType)
        else:
            movable = True
            if not hasattr(self.obj, "Placement"):
                movable = False
            if 'Hidden' in self.obj.getEditorMode(
                    "Placement") or 'ReadOnly' in self.obj.getEditorMode(
                        "Placement"):
                movable = False
            if not movable:
                if self.callback_Cancel:
                    self.callback_Cancel()
                raise ValueError(
                    _translate(
                        'AttachmentEditor',
                        "Object {name} is neither movable nor attachable, can't edit attachment",
                        None).format(name=self.obj.Label))

            self.obj_is_attachable = False
            self.attacher = Part.AttachEngine()

            mb = QtGui.QMessageBox()
            mb.setIcon(mb.Icon.Warning)
            mb.setText(
                _translate(
                    'AttachmentEditor',
                    "{obj} is not attachable. You can still use attachment editor dialog to align the object, but the attachment won't be parametric.",
                    None).format(obj=obj_to_attach.Label))
            mb.setWindowTitle(
                _translate('AttachmentEditor', "Attachment", None))
            btnAbort = mb.addButton(QtGui.QMessageBox.StandardButton.Abort)
            btnOK = mb.addButton(
                _translate('AttachmentEditor', "Continue", None),
                QtGui.QMessageBox.ButtonRole.ActionRole)
            mb.setDefaultButton(btnOK)
            mb.exec_()
            if mb.clickedButton() is btnAbort:
                if self.callback_Cancel:
                    self.callback_Cancel()
                raise CancelError()

        import os
        self.form = uic.loadUi(
            os.path.dirname(__file__) + os.path.sep +
            'TaskAttachmentEditor.ui')
        self.form.setWindowIcon(QtGui.QIcon(':/icons/Part_Attachment.svg'))
        self.form.setWindowTitle(
            _translate('AttachmentEditor', "Attachment", None))

        self.refLines = [
            self.form.lineRef1, self.form.lineRef2, self.form.lineRef3,
            self.form.lineRef4
        ]
        self.refButtons = [
            self.form.buttonRef1, self.form.buttonRef2, self.form.buttonRef3,
            self.form.buttonRef4
        ]
        self.attachmentOffsetEdits = [
            self.form.attachmentOffsetX, self.form.attachmentOffsetY,
            self.form.attachmentOffsetZ, self.form.attachmentOffsetYaw,
            self.form.attachmentOffsetPitch, self.form.attachmentOffsetRoll
        ]

        self.block = False

        for i in range(len(self.refLines)):
            QtCore.QObject.connect(
                self.refLines[i],
                QtCore.SIGNAL('textEdited(QString)'),
                lambda txt, i=i: self.lineRefChanged(i, txt))

        for i in range(len(self.refLines)):
            QtCore.QObject.connect(self.refButtons[i],
                                   QtCore.SIGNAL('clicked()'),
                                   lambda i=i: self.refButtonClicked(i))

        for i in range(len(self.attachmentOffsetEdits)):
            QtCore.QObject.connect(
                self.attachmentOffsetEdits[i],
                QtCore.SIGNAL('valueChanged(double)'),
                lambda val, i=i: self.attachmentOffsetChanged(i, val))

        QtCore.QObject.connect(self.form.checkBoxFlip,
                               QtCore.SIGNAL('clicked()'),
                               self.checkBoxFlipClicked)

        QtCore.QObject.connect(self.form.listOfModes,
                               QtCore.SIGNAL('itemSelectionChanged()'),
                               self.modeSelected)

        if self.create_transaction:
            self.obj.Document.openTransaction(
                _translate('AttachmentEditor', "Edit attachment of {feat}",
                           None).format(feat=self.obj.Name))

        self.readParameters()

        if len(self.attacher.References) == 0 and take_selection:
            sel = GetSelectionAsLinkSubList()
            for i in range(len(sel))[::-1]:
                if sel[i][0] is obj_to_attach:
                    sel.pop(i)
            self.attacher.References = sel
            # need to update textboxes
            self.fillAllRefLines()

        if len(self.attacher.References) == 0:
            self.i_active_ref = 0
            self.auto_next = True
        else:
            self.i_active_ref = -1
            self.auto_next = False

        Gui.Selection.addObserver(self)

        self.updatePreview()
        self.updateRefButtons()

        self.tv = TempoVis(self.obj.Document,
                           tag="PartGui.TaskAttachmentEditor")
        if self.tv:  # tv will still be None if Show module is unavailable
            self.tv.hide_all_dependent(self.obj)
            self.tv.show(self.obj)
            self.tv.setUnpickable(self.obj)
            self.tv.modifyVPProperty(self.obj, "Transparency", 70)
            self.tv.show([obj for (obj, subname) in self.attacher.References])
Exemple #54
0
    def setupUi(self):
        """Bruh"""
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setGeometry(50, 50, 600, 300)
        self.setWindowTitle("ZeZe's TWTools - Backtiming Calculator")
        self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))

        """Background color"""
        self.backgroundPalette = QtGui.QPalette()
        self.backgroundColor = QtGui.QColor(217, 204, 170)
        self.backgroundPalette.setColor(
            QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(self.backgroundPalette)

        """Main layout & return to main menu button"""
        self.verticalLayout = QtGui.QVBoxLayout(self)

        self.buttonLayout = QtGui.QHBoxLayout(self)
        self.verticalLayout.addLayout(self.buttonLayout)
        self.returnButton = QtGui.QPushButton("  Return to the Main Menu  ", self)
        self.returnButton.clicked.connect(self.return_function)
        self.buttonLayout.addWidget(self.returnButton)
        self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.buttonLayout.addItem(self.buttonSpacer)

        """Line Spacer and line"""
        self.lineSpacer = QtGui.QSpacerItem(40, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.verticalLayout.addItem(self.lineSpacer)
        self.line = QtGui.QFrame(self)
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.verticalLayout.addWidget(self.line)

        """Settings radio buttons"""
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.verticalLayout_2 = QtGui.QVBoxLayout()
        self.horizontalLayout_2.addLayout(self.verticalLayout_2)

        self.selected_worldRadio = QtGui.QRadioButton("Use Selected World", self)
        self.selected_worldRadio.toggled.connect(self.selected_function)
        self.verticalLayout_2.addWidget(self.selected_worldRadio)

        self.manual_speedRadio = QtGui.QRadioButton("Input Speed Manually", self)
        self.manual_speedRadio.toggled.connect(self.manual_function)
        self.verticalLayout_2.addWidget(self.manual_speedRadio)

        """Speed labels"""
        self.speed_labelsLayout = QtGui.QVBoxLayout()
        self.horizontalLayout_2.addLayout(self.speed_labelsLayout)

        self.world_speedLabel = QtGui.QLabel(self)
        self.world_speedLabel.setText("World Speed:")
        self.speed_labelsLayout.addWidget(self.world_speedLabel)

        self.unit_speedLabel = QtGui.QLabel(self)
        self.unit_speedLabel.setText("Unit Speed:")
        self.speed_labelsLayout.addWidget(self.unit_speedLabel)

        """Spacer"""
        self.Spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.verticalLayout.addItem(self.Spacer)

        """Botton layout"""
        self.horizontalLayout_3 = QtGui.QHBoxLayout()
        self.verticalLayout.addLayout(self.horizontalLayout_3)

        """Bottom left layout"""
        self.verticalLayout_4 = QtGui.QVBoxLayout()
        self.horizontalLayout_3.addLayout(self.verticalLayout_4)

        """Settings layout"""
        self.horizontalLayout_4 = QtGui.QHBoxLayout()
        self.verticalLayout_4.addLayout(self.horizontalLayout_4)

        """Origin and destination"""
        self.verticalLayout_6 = QtGui.QVBoxLayout()
        self.horizontalLayout_4.addLayout(self.verticalLayout_6)

        self.originLabel = QtGui.QLabel(self)
        self.originLabel.setText("Origin:")
        self.verticalLayout_6.addWidget(self.originLabel)

        self.originEdit = QtGui.QLineEdit(self)
        self.originEdit.setText("500|500")
        self.verticalLayout_6.addWidget(self.originEdit)

        self.destinationLabel = QtGui.QLabel(self)
        self.destinationLabel.setText("Destination:")
        self.verticalLayout_6.addWidget(self.destinationLabel)

        self.destinationEdit = QtGui.QLineEdit(self)
        self.destinationEdit.setText("550|550")
        self.verticalLayout_6.addWidget(self.destinationEdit)

        """Unit and arrival"""
        self.verticalLayout_7 = QtGui.QVBoxLayout()
        self.horizontalLayout_4.addLayout(self.verticalLayout_7)

        self.unitLabel = QtGui.QLabel(self)
        self.unitLabel.setText("Unit:")
        self.verticalLayout_7.addWidget(self.unitLabel)

        self.unitBox = QtGui.QComboBox(self)
        self.unitBox.addItem("Spear fighter")
        self.unitBox.addItem("Swordsman")
        self.unitBox.addItem("Axeman")
        self.unitBox.addItem("Archer")
        self.unitBox.addItem("Scout")
        self.unitBox.addItem("Light cavalry")
        self.unitBox.addItem("Mounted archer")
        self.unitBox.addItem("Heavy cavalry")
        self.unitBox.addItem("Ram")
        self.unitBox.addItem("Catapult")
        self.unitBox.addItem("Paladin")
        self.unitBox.addItem("Nobleman")

        self.verticalLayout_7.addWidget(self.unitBox)

        self.arrivalLabel = QtGui.QLabel(self)
        self.arrivalLabel.setText("Arrival:")
        self.verticalLayout_7.addWidget(self.arrivalLabel)

        self.arrivalEdit = QtGui.QDateTimeEdit(self)
        self.verticalLayout_7.addWidget(self.arrivalEdit)

        """Button and text edit"""
        self.calculateButton = QtGui.QPushButton(self)
        self.calculateButton.setText("Calculate Backtime")
        self.calculateButton.clicked.connect(self.backtime_function)
        self.verticalLayout_4.addWidget(self.calculateButton)

        self.backtimeEdit = QtGui.QTextEdit(self)
        self.horizontalLayout_3.addWidget(self.backtimeEdit)
Exemple #55
0
def main():
    # QtGui.QApplication.setStyle("plastique")
    # QtGui.QApplication.setStyleSheet("background-color: #407040; color: white")
    app = QtGui.QApplication(sys.argv)
    MainWindow().run(app)
Exemple #56
0
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(369, 445)
        self.horizontalLayout_2 = QtGui.QHBoxLayout(Form)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.verticalLayout_5 = QtGui.QVBoxLayout()
        self.verticalLayout_5.setObjectName("verticalLayout_5")
        self.verticalLayout_3 = QtGui.QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.ControlObjectGroupBox = QtGui.QGroupBox(Form)
        self.ControlObjectGroupBox.setObjectName("ControlObjectGroupBox")
        self.verticalLayout = QtGui.QVBoxLayout(self.ControlObjectGroupBox)
        self.verticalLayout.setObjectName("verticalLayout")
        self.LoadSelectionAsCntrlObjPushBtn = QtGui.QPushButton(
            self.ControlObjectGroupBox)
        self.LoadSelectionAsCntrlObjPushBtn.setObjectName(
            "LoadSelectionAsCntrlObjPushBtn")
        self.verticalLayout.addWidget(self.LoadSelectionAsCntrlObjPushBtn)
        self.ControllineEdit = QtGui.QLineEdit(self.ControlObjectGroupBox)
        self.ControllineEdit.setEnabled(False)
        self.ControllineEdit.setObjectName("ControllineEdit")
        self.verticalLayout.addWidget(self.ControllineEdit)
        self.verticalLayout_3.addWidget(self.ControlObjectGroupBox)
        self.VisibilitySwitchGroupBox = QtGui.QGroupBox(Form)
        self.VisibilitySwitchGroupBox.setObjectName("VisibilitySwitchGroupBox")
        self.verticalLayout_6 = QtGui.QVBoxLayout(
            self.VisibilitySwitchGroupBox)
        self.verticalLayout_6.setObjectName("verticalLayout_6")
        self.label = QtGui.QLabel(self.VisibilitySwitchGroupBox)
        self.label.setObjectName("label")
        self.verticalLayout_6.addWidget(self.label)
        self.VisibilityNameTxt = QtGui.QLineEdit(self.VisibilitySwitchGroupBox)
        self.VisibilityNameTxt.setObjectName("VisibilityNameTxt")
        self.verticalLayout_6.addWidget(self.VisibilityNameTxt)
        self.CreateVisibilitySwitchBtn = QtGui.QPushButton(
            self.VisibilitySwitchGroupBox)
        self.CreateVisibilitySwitchBtn.setMinimumSize(QtCore.QSize(0, 34))
        self.CreateVisibilitySwitchBtn.setObjectName(
            "CreateVisibilitySwitchBtn")
        self.verticalLayout_6.addWidget(self.CreateVisibilitySwitchBtn)
        self.verticalLayout_3.addWidget(self.VisibilitySwitchGroupBox)
        self.VisibilityGroup = QtGui.QGroupBox(Form)
        self.VisibilityGroup.setObjectName("VisibilityGroup")
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.VisibilityGroup)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.RemoveEnumBtn = QtGui.QPushButton(self.VisibilityGroup)
        self.RemoveEnumBtn.setMinimumSize(QtCore.QSize(0, 0))
        self.RemoveEnumBtn.setMaximumSize(QtCore.QSize(16777215, 100))
        self.RemoveEnumBtn.setIconSize(QtCore.QSize(16, 16))
        self.RemoveEnumBtn.setObjectName("RemoveEnumBtn")
        self.verticalLayout_2.addWidget(self.RemoveEnumBtn)
        self.ObjectSpaceListView = QtGui.QListWidget(self.VisibilityGroup)
        self.ObjectSpaceListView.setObjectName("ObjectSpaceListView")
        self.verticalLayout_2.addWidget(self.ObjectSpaceListView)
        self.verticalLayout_3.addWidget(self.VisibilityGroup)
        self.verticalLayout_5.addLayout(self.verticalLayout_3)
        self.horizontalLayout_2.addLayout(self.verticalLayout_5)
        self.AffectedVisibilityObjects = QtGui.QGroupBox(Form)
        self.AffectedVisibilityObjects.setObjectName(
            "AffectedVisibilityObjects")
        self.verticalLayout_4 = QtGui.QVBoxLayout(
            self.AffectedVisibilityObjects)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.RemoveFromVisibilityBtn = QtGui.QPushButton(
            self.AffectedVisibilityObjects)
        self.RemoveFromVisibilityBtn.setMinimumSize(QtCore.QSize(0, 0))
        self.RemoveFromVisibilityBtn.setMaximumSize(QtCore.QSize(
            16777215, 100))
        self.RemoveFromVisibilityBtn.setIconSize(QtCore.QSize(16, 16))
        self.RemoveFromVisibilityBtn.setObjectName("RemoveFromVisibilityBtn")
        self.verticalLayout_4.addWidget(self.RemoveFromVisibilityBtn)
        self.RemoveListSelectedBtn = QtGui.QPushButton(
            self.AffectedVisibilityObjects)
        self.RemoveListSelectedBtn.setMinimumSize(QtCore.QSize(0, 0))
        self.RemoveListSelectedBtn.setMaximumSize(QtCore.QSize(16777215, 100))
        self.RemoveListSelectedBtn.setIconSize(QtCore.QSize(16, 16))
        self.RemoveListSelectedBtn.setObjectName("RemoveListSelectedBtn")
        self.verticalLayout_4.addWidget(self.RemoveListSelectedBtn)
        self.AddToVisibilitySwitchBtn = QtGui.QPushButton(
            self.AffectedVisibilityObjects)
        self.AddToVisibilitySwitchBtn.setObjectName("AddToVisibilitySwitchBtn")
        self.verticalLayout_4.addWidget(self.AddToVisibilitySwitchBtn)
        self.ConstrainedObjectListView = QtGui.QListWidget(
            self.AffectedVisibilityObjects)
        self.ConstrainedObjectListView.setObjectName(
            "ConstrainedObjectListView")
        self.verticalLayout_4.addWidget(self.ConstrainedObjectListView)
        self.horizontalLayout_2.addWidget(self.AffectedVisibilityObjects)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
Exemple #57
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(572, 382)
        self.gridLayout_2 = QtGui.QGridLayout(Dialog)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.history_edit = QtGui.QPlainTextEdit(Dialog)
        self.history_edit.setReadOnly(True)
        self.history_edit.setCenterOnScroll(False)
        self.history_edit.setObjectName("history_edit")
        self.verticalLayout.addWidget(self.history_edit)
        self.gridLayout_2.addLayout(self.verticalLayout, 1, 0, 1, 1)
        self.horizontalLayout_3 = QtGui.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.refresh_Btn = QtGui.QPushButton(Dialog)
        self.refresh_Btn.setObjectName("refresh_Btn")
        self.horizontalLayout_3.addWidget(self.refresh_Btn)
        self.commands_only = QtGui.QCheckBox(Dialog)
        self.commands_only.setObjectName("commands_only")
        self.horizontalLayout_3.addWidget(self.commands_only)
        self.user_com_btn = QtGui.QCheckBox(Dialog)
        self.user_com_btn.setObjectName("user_com_btn")
        self.horizontalLayout_3.addWidget(self.user_com_btn)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem)
        self.gridLayout_2.addLayout(self.horizontalLayout_3, 0, 0, 1, 1)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.clear_history_btn = QtGui.QPushButton(Dialog)
        self.clear_history_btn.setObjectName("clear_history_btn")
        self.horizontalLayout.addWidget(self.clear_history_btn)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.gridLayout_2.addLayout(self.horizontalLayout, 2, 0, 1, 1)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
Exemple #58
0
 def _initCreateTaskAction(self):
     action = QtGui.QAction(getIcon('add.png'), '&Create Task', self)
     action.setShortcuts(['Insert', 'Ctrl+I', 'Ctrl+N'])
     action.triggered.connect(self.createTask)
     self._view.addListAction(action)
     self.createTaskAction = action
Exemple #59
0
 def showErrorMessage(err):
     message = str(err)
     dialog = QtGui.QMessageBox(QtGui.QMessageBox.Critical, 'Error',
                                message)
     dialog.setWindowModality(QtCore.Qt.ApplicationModal)
     dialog.exec_()
Exemple #60
0
    def setupUi(self):
        """Bruh"""
        self.setGeometry(50, 50, 850, 425)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle("ZeZe's TWTools")
        self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))

        """Set background color"""
        self.backgroundPalette = QtGui.QPalette()
        self.backgroundColor = QtGui.QColor(217, 204, 170)
        self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
        self.setPalette(self.backgroundPalette)

        """Layout for dialog"""
        self.verticalLayout = QtGui.QVBoxLayout(self)

        """Return button"""
        self.buttonLayout = QtGui.QHBoxLayout(self)
        self.verticalLayout.addLayout(self.buttonLayout)
        self.returnButton = QtGui.QPushButton("  Return to the Main Menu  ", self)
        self.returnButton.clicked.connect(self.return_function)
        self.buttonLayout.addWidget(self.returnButton)
        self.buttonSpacer = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.buttonLayout.addItem(self.buttonSpacer)

        """Line Spacer and line"""
        self.lineSpacer = QtGui.QSpacerItem(40, 5, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.verticalLayout.addItem(self.lineSpacer)
        self.line = QtGui.QFrame(self)
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.verticalLayout.addWidget(self.line)

        """Layout for form and table"""
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.verticalLayout.addLayout(self.horizontalLayout)

        """Layout for form"""
        self.formLayout = QtGui.QFormLayout()
        self.horizontalLayout.addLayout(self.formLayout)

        """Search around Form[0]"""
        self.searchLabel = QtGui.QLabel("Search around", self)
        self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.searchLabel)

        self.searchEdit = QtGui.QLineEdit(self)
        self.searchEdit.setText("500|500")
        self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.searchEdit)

        """Spacer Form[1]"""
        self.Spacer1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.formLayout.setItem(1, QtGui.QFormLayout.FieldRole, self.Spacer1)

        """Filter by Form[2]"""
        self.filterLabel = QtGui.QLabel("Filter by", self)
        self.formLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.filterLabel)

        self.filterBox = QtGui.QComboBox(self)
        self.filterBox.addItem("Players")
        self.filterBox.addItem("Barbarian Villages")
        self.filterBox.addItem("Players and Barbarians")
        self.formLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.filterBox)

        """Spacer Form[3]"""
        self.Spacer2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.formLayout.setItem(3, QtGui.QFormLayout.FieldRole, self.Spacer2)

        """Min points Form[4]"""
        self.min_pointsLabel = QtGui.QLabel("Min points", self)
        self.formLayout.setWidget(4, QtGui.QFormLayout.LabelRole, self.min_pointsLabel)

        self.min_pointsEdit = QtGui.QLineEdit(self)
        self.min_pointsEdit.setText("26")
        self.formLayout.setWidget(4, QtGui.QFormLayout.FieldRole, self.min_pointsEdit)

        """Max points Form"""
        self.max_pointsLabel = QtGui.QLabel("Max points", self)
        self.formLayout.setWidget(5, QtGui.QFormLayout.LabelRole, self.max_pointsLabel)

        self.max_pointsEdit = QtGui.QLineEdit(self)
        self.max_pointsEdit.setText("12393")
        self.formLayout.setWidget(5, QtGui.QFormLayout.FieldRole, self.max_pointsEdit)

        """Range Form[6]"""
        self.min_rangeLabel = QtGui.QLabel("Min range", self)
        self.formLayout.setWidget(6, QtGui.QFormLayout.LabelRole, self.min_rangeLabel)

        self.min_rangeEdit = QtGui.QLineEdit(self)
        self.min_rangeEdit.setText("0")
        self.formLayout.setWidget(6, QtGui.QFormLayout.FieldRole, self.min_rangeEdit)

        """Range Form[7]"""
        self.max_rangeLabel = QtGui.QLabel("Max range", self)
        self.formLayout.setWidget(7, QtGui.QFormLayout.LabelRole, self.max_rangeLabel)

        self.max_rangeEdit = QtGui.QLineEdit(self)
        self.max_rangeEdit.setText("25")
        self.formLayout.setWidget(7, QtGui.QFormLayout.FieldRole, self.max_rangeEdit)

        """Picture Form[8]"""
        self.testLabel = QtGui.QLabel(self)
        self.pixmap = QtGui.QPixmap(resource_path("images/pic.jpg"))
        self.testLabel.setPixmap(self.pixmap)
        self.formLayout.setWidget(8, QtGui.QFormLayout.FieldRole, self.testLabel)

        """Go button Form[9]"""
        self.goButton = QtGui.QPushButton("Go", self)
        self.goButton.clicked.connect(self.go_function)
        self.formLayout.setWidget(9, QtGui.QFormLayout.FieldRole, self.goButton)

        """Table widget & options"""
        self.tableWidget = QtGui.QTableWidget(self)
        self.horizontalLayout.addWidget(self.tableWidget)
        self.tableWidget.setShowGrid(False)
        self.tableWidget.setWordWrap(False)
        self.tableWidget.setCornerButtonEnabled(False)
        self.tableWidget.setSortingEnabled(True)
        self.tableWidget.verticalHeader().setVisible(False)
        self.tableWidget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
        self.tableWidget.setSelectionMode(QtGui.QAbstractItemView.NoSelection)

        """Table columns"""
        self.tableWidget.setColumnCount(4)
        item = QtGui.QTableWidgetItem("Player")
        self.tableWidget.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem("Name")
        self.tableWidget.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem("Coordinates")
        self.tableWidget.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem("Points")
        self.tableWidget.setHorizontalHeaderItem(3, item)

        """Spacer, line and layout for coords output options panel"""
        self.Spacer = QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.verticalLayout.addItem(self.Spacer)

        self.line = QtGui.QFrame(self)
        self.line.setFrameShape(QtGui.QFrame.HLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.verticalLayout.addWidget(self.line)

        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.verticalLayout.addLayout(self.horizontalLayout_2)

        self.Spacer1 = QtGui.QSpacerItem(10, 5, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.horizontalLayout_2.addItem(self.Spacer1)

        """Radio buttons for output options"""
        self.verticalLayout_2 = QtGui.QVBoxLayout()
        self.horizontalLayout_2.addLayout(self.verticalLayout_2)

        self.outputLabel = QtGui.QLabel("Output as: ", self)
        self.verticalLayout_2.addWidget(self.outputLabel)

        self.plainRadio = QtGui.QRadioButton("Plain coordinates (useful for scripts)", self)
        self.plainRadio.toggled.connect(self.list_options_toggle)
        self.plainRadio.toggled.connect(self.get_coords_data)

        self.verticalLayout_2.addWidget(self.plainRadio)

        self.listRadio = QtGui.QRadioButton("Formatted list (BB-code)", self)
        self.listRadio.toggled.connect(self.get_coords_data)
        self.verticalLayout_2.addWidget(self.listRadio)

        """Checkbox for list output options"""
        self.verticalLayout_3 = QtGui.QVBoxLayout()
        self.horizontalLayout_2.addLayout(self.verticalLayout_3)

        self.Spacer2 = QtGui.QSpacerItem(5, 1.75, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
        self.verticalLayout_3.addItem(self.Spacer2)

        self.formWidget = QtGui.QWidget()
        self.verticalLayout_3.addWidget(self.formWidget)

        self.formLayout = QtGui.QFormLayout()
        self.formWidget.setLayout(self.formLayout)
        self.formLayout.setFieldGrowthPolicy(QtGui.QFormLayout.AllNonFixedFieldsGrow)

        self.numberCheck = QtGui.QCheckBox("Incrementing number", self)
        self.numberCheck.toggled.connect(self.get_coords_data)
        self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.numberCheck)

        self.playerCheck = QtGui.QCheckBox("Player names", self)
        self.playerCheck.toggled.connect(self.get_coords_data)
        self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.playerCheck)

        self.pointsCheck = QtGui.QCheckBox("Village points", self)
        self.pointsCheck.toggled.connect(self.get_coords_data)
        self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.pointsCheck)

        self.plainRadio.toggle()

        """Coords edit box"""
        self.coordsEdit = QtGui.QTextEdit(self)
        self.verticalLayout.addWidget(self.coordsEdit)