def load_bottom_stylesheet(self, bottom_widget): if QDir.setCurrent('./data/gfx/table/default/'): bottom_widget.setStyleSheet(common.loadStyleSheet('style.css')) QDir.setCurrent('../../../../')
def __init__(self, parent): super(MdiTable, self).__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle(self.tr('Table titilonius')) #self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint) self.setMinimumHeight(200) self.pic = QtGui.QPixmap('./data/gfx/table/default/table.png') scene = QtGui.QGraphicsScene(self) scene.setBackgroundBrush(parent.mdiArea.background()) #seat = scene.addPixmap(self.pic) seat = Interactable(self.pic, self) seat.setTransformationMode(QtCore.Qt.SmoothTransformation) scene.addItem(seat) self.disppic = scene.items()[0] #self.view = QtGui.QGraphicsView() self.view = NonScrollGraphicsView() self.view.setScene(scene) self.view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.view.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.view.setAlignment(QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.setWidget(self.view) #scroll = ScrollEater(self.view) #self.view.installEventFilter(scroll) #self.view.clearFocus() #self.view.setFocusPolicy(QtCore.Qt.NoFocus) #self.seat = QtGui.QPixmap('./data/gfx/table/default/seat_empty.png') self.seat_boy = QtGui.QPixmap('./data/gfx/table/default/boy.png') self.seat_girl = QtGui.QPixmap('./data/gfx/table/default/girl.png') self.seat_custom = QtGui.QPixmap('./data/gfx/table/default/custom-avatar.png') #avatarPositions = [(610, 100), (620, 200), (510, 290), (330, 290), (140, 290), (30, 200), (60, 100), (240, 60), (430, 60), (80, 80)] avatarPositions = [ (600, 38), (660, 170), (485, 360), (270, 360), (100, 327), (42, 168), (81, 77), (290, 20), (400, 20), (628, 319)] #avatarPositions = [(40, 170), (470, 280), (200, 280), (630, 170), (200, 40), (470, 40)] self.allSeats = [] for p in avatarPositions: #for p in []: choice = random.randint(0,2) if choice == 0: seat = scene.addPixmap(self.seat_boy) elif choice == 1: seat = scene.addPixmap(self.seat_girl) else: seat = scene.addPixmap(self.seat_custom) seat.setTransformationMode(QtCore.Qt.SmoothTransformation) seat.setFlags(seat.ItemIsMovable) seat.setPos(*p) self.allSeats.append(seat) #seat = scene.addPixmap(self.seat) """seat.setPos(80,220) seat.setTransformationMode(QtCore.Qt.SmoothTransformation) seat = scene.addPixmap(self.seat) seat.setPos(60,30) seat.setTransformationMode(QtCore.Qt.SmoothTransformation) seat = scene.addPixmap(self.seat) seat.setPos(20,120) seat.setTransformationMode(QtCore.Qt.SmoothTransformation) seat = scene.addPixmap(self.seat) seat.setPos(460,120) seat.setTransformationMode(QtCore.Qt.SmoothTransformation)""" self.other = QtGui.QPixmap('./data/gfx/table/default/other_cards.png') #positions = [(610, 120), (620, 200), (510, 290), (330, 290), (140, 290), (100, 210), (120, 120), (280, 110), (480, 110)] positions = [(625, 210), (250, 80), (250, 320), (100, 210), (470, 80)] self.allCards = [] #for p in positions: for p in []: #other = Interactable(self.other, self) other = scene.addPixmap(self.other) other.setTransformationMode(QtCore.Qt.SmoothTransformation) other.setFlags(other.ItemIsMovable) other.setPos(*p) self.allCards.append(other) #scene.addItem(other) """other = scene.addPixmap(self.other) other.setPos(80, 130) other.setTransformationMode(QtCore.Qt.SmoothTransformation) other = scene.addPixmap(self.other) other.setPos(120, 200) other.setTransformationMode(QtCore.Qt.SmoothTransformation) other = scene.addPixmap(self.other) other.setPos(440, 120) other.setTransformationMode(QtCore.Qt.SmoothTransformation) #other = scene.addPixmap(self.other) other = Interactable(self.other) other.setPos(380, 50) other.setTransformationMode(QtCore.Qt.SmoothTransformation) scene.addItem(other)""" font = QtGui.QFont('Lucida Sans') font.setPointSize(10) font1 = QtGui.QFont('Lucida Sans') font1.setPointSize(10) font1.setWeight(QtGui.QFont.Black) brush = QtGui.QLinearGradient() brush.setColorAt(0, QtCore.Qt.white) #brush = QtGui.QBrush() #brush.setColor(QtCore.Qt.white) pen = QtGui.QPen() pen.setWidth(0) pen.setStyle(QtCore.Qt.NoPen) names = [ "Tracy", "Genjix", "derp-derp", "KibKibKib", "Tracy", "Genjix", "derp-derp", "KibKibKib", "drawingfishe", "scribl"] stacks = [ '1200 btc', '8000 btc', '100 btc', '9112 btc', '1200 btc', '8000 btc', '100 btc', '9112 btc', '7654 btc', '400 btc'] playbox = QtGui.QPixmap('./data/gfx/table/default/playerbox.png') self.allPlayboxes = [] playboxPositions = [ (377, 380), (652, 257), (638, 123), (260, 443), (580, 407), (85, 412), (31, 261), (180, 13), (493, 46), (21, 30)] for p in playboxPositions: path = QtGui.QPainterPath() play = scene.addPixmap(playbox) play.setFlags(play.ItemIsMovable) self.allPlayboxes.append(play) p = [p[0], p[1]] play.setPos(p[0], p[1]) p[0] += 10 p[1] += 4 p = p[0], p[1] + 12 path.addText(QtCore.QPointF(p[0], p[1]), font, names.pop()) p = p[0], p[1] + 15 path.addText(QtCore.QPointF(p[0], p[1]), font1, stacks.pop()) scene.addPath(path, pen, brush) ranks = "23456789tjqka" suits = "hdcs" deck = [rank + suit for rank in ranks for suit in suits] deckGraphics = [QtSvg.QGraphicsSvgItem('./data/gfx/cards/replixanax/%s.svg'%card) for card in deck] random.shuffle(deckGraphics) for i in range(5): card = deckGraphics.pop() scene.addItem(card) card.setScale(0.8) card.setPos(280 + 50*i, 175) for p in avatarPositions: card = deckGraphics.pop() scene.addItem(card) card.setScale(0.8) p = p[0] - 10, p[1] - 5 card.setPos(p[0], p[1]) card = deckGraphics.pop() scene.addItem(card) card.setScale(0.8) p = p[0] + 22, p[1] + 10 card.setPos(p[0], p[1]) chips = [ QtGui.QPixmap('./data/gfx/chips/default/chip0001.png'), QtGui.QPixmap('./data/gfx/chips/default/chip000025.png'), QtGui.QPixmap('./data/gfx/chips/default/chip000005.png')] def addchip(chip, scene, pos): other = scene.addPixmap(chip) other.setTransformationMode(QtCore.Qt.SmoothTransformation) other.setFlags(other.ItemIsMovable) other.setPos(*pos) start = 260 off = 6 addchip(chips[0], scene, (300, start)) addchip(chips[0], scene, (300, start - off)) addchip(chips[0], scene, (300, start - 2*off)) addchip(chips[0], scene, (300, start - 3*off)) addchip(chips[0], scene, (300, start - 4*off)) addchip(chips[1], scene, (330, start)) addchip(chips[1], scene, (330, start - off)) addchip(chips[1], scene, (330, start - 2*off)) addchip(chips[2], scene, (360, start)) self.wgt = QtGui.QWidget() hbox = QtGui.QHBoxLayout() hbox.addStretch() fold = QtGui.QPushButton('Fold') fold.setObjectName('FoldBtn') #fold.setStyleSheet('background-color: #1169a4; width: 80px; font-size: 10pt; font-weight: bold; color: white;') fold.setCheckable(True) fold.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) hbox.addWidget(fold) call = QtGui.QPushButton('Call\n$1') call.setObjectName('CallBtn') #call.setStyleSheet('background-color: #1169a4; width: 80px; font-size: 10pt; font-weight: bold; color: white;') call.setCheckable(True) call.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) hbox.addWidget(call) hbox.addSpacing(20) rai = QtGui.QPushButton('Raise\n$2') rai.setObjectName('RaiseBtn') #rai.setStyleSheet('background-color: #1169a4; color: #ddf; width: 80px; height: 50px; font-size: 10pt; font-weight: bold;') rai.setCheckable(True) rai.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Minimum) hbox.addWidget(rai) self.edit = QtGui.QLineEdit() self.edit.setValidator(QtGui.QDoubleValidator(0.0, -1.0, 2, self.edit)) self.edit.setMaximumSize(60,28) self.edit.setText('1') #hbox.addWidget(self.edit, 0.2) self.slider = QtGui.QSlider(QtCore.Qt.Vertical) self.slider.setTickPosition(self.slider.TicksBelow) #self.slider.setStyleSheet('background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);') self.slider.valueChanged.connect(self.sliderMoved) self.edit.textChanged.connect(self.textChanged) #hbox.addWidget(self.slider) self.wgt.resize(500,100) #self.btn = QtGui.QPushButton('play') #self.btn.setAttribute(QtCore.Qt.WA_NoSystemBackground) self.wgt.setAttribute(QtCore.Qt.WA_NoSystemBackground) vboxnum = QtGui.QVBoxLayout() vboxnum.addStretch() vboxnum.addWidget(self.edit) hboxslider = QtGui.QHBoxLayout() hboxslider.addStretch() hboxslider.addLayout(vboxnum) hboxslider.addWidget(self.slider) vbox = QtGui.QVBoxLayout(self.wgt) #vbox.addStretch() vbox.addLayout(hboxslider) vbox.addLayout(hbox) size = self.pic.size() self.wgt.resize(size.width(), size.height()) if QtCore.QDir.setCurrent('./data/gfx/table/default/'): self.wgt.setStyleSheet(str(common.loadStyleSheet('style.css'))) QtCore.QDir.setCurrent('../../../../') scene.addWidget(self.wgt) self.view.setRenderHints(QtGui.QPainter.Antialiasing|QtGui.QPainter.SmoothPixmapTransform)
def __init__(self): super(TableWindow, self).__init__() playerList = QTreeWidget() playerList.setColumnCount(2) playerList.setHeaderLabels(['Nickname', 'Stack']) #playerList.header().hide() players = [] andy = QTreeWidgetItem(['andy', '80']) players.append(andy) Chisness = QTreeWidgetItem(['Chisness', '112']) players.append(Chisness) WizardOfAhns = QTreeWidgetItem(['WizardOfAhns', '98']) players.append(WizardOfAhns) DrawingFishe = QTreeWidgetItem(['DrawingFishe', '120']) players.append(DrawingFishe) genjix = QTreeWidgetItem(['genjix', '100']) players.append(genjix) JimiThing34 = QTreeWidgetItem(['Jimithing34', '100']) players.append(JimiThing34) JimiThing34 = QTreeWidgetItem(['', '']) players.append(JimiThing34) JimiThing34 = QTreeWidgetItem(['Pot size', '20']) players.append(JimiThing34) mainpot = QTreeWidgetItem(['Main pot', '15']) sidepot = QTreeWidgetItem(['Side pot', '5']) JimiThing34.addChild(mainpot) JimiThing34.addChild(sidepot) playerList.addTopLevelItems(players) playerNotesSplitter = QSplitter() playerNotesSplitter.setOrientation(Qt.Vertical) playerNotesSplitter.addWidget(playerList) dock = QDockWidget(self.tr("Players")) dock.setAllowedAreas(Qt.LeftDockWidgetArea|Qt.RightDockWidgetArea) dock.setWidget(playerList) self.addDockWidget(Qt.LeftDockWidgetArea, dock) notesSection = QWidget() notes = QTextEdit() notes.setHtml('This player is a <i>real</i> <b>donk</b>!<br /><h1>NEVER BLUFF HIM!!</h1>') dock = QDockWidget(self.tr("Notes")) dock.setAllowedAreas(Qt.LeftDockWidgetArea|Qt.RightDockWidgetArea) dock.setWidget(notes) self.addDockWidget(Qt.LeftDockWidgetArea, dock) #handhist = QtWebKit.QWebView() handhist = QTextEdit() #handhist.setHtml(hand2.handhistory) handhist.setText(hand2.handhistory) handhist.setReadOnly(True) #handhist.verticalScrollBar().setSliderPosition(handhist.verticalScrollBar().maximum()) #handhist.setStyleSheet('background-color: #ddd;') #----------------- self.wgt = QWidget() hbox = QHBoxLayout(self.wgt) hbox.addStretch() card = QLabel() image = QImage('data/gfx/cards/nobus/Ad.png') card.setPixmap(QPixmap.fromImage(image)) hbox.addWidget(card) card = QLabel() image = QImage('data/gfx/cards/nobus/Ac.png') card.setPixmap(QPixmap.fromImage(image)) hbox.addWidget(card) hbox.addSpacing(20) fold = QPushButton('Fold') fold.setObjectName('FoldBtn') fold.setCheckable(True) fold.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) hbox.addWidget(fold) call = QPushButton('Call\n$1') call.setObjectName('CallBtn') #call.setStyleSheet('background-color: #1169a4; width: 80px; font-size: 10pt; font-weight: bold; color: white;') call.setCheckable(True) call.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) hbox.addWidget(call) hbox.addSpacing(20) rai = QPushButton('Raise\n$2') rai.setObjectName('RaiseBtn') #rai.setStyleSheet('background-color: #1169a4; color: #ddf; width: 80px; height: 50px; font-size: 10pt; font-weight: bold;') rai.setCheckable(True) rai.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) hbox.addWidget(rai) self.edit = QLineEdit() self.edit.setValidator(QDoubleValidator(0.0, -1.0, 2, self.edit)) self.edit.setMaximumSize(40,28) self.edit.setText('1') if QDir.setCurrent('./data/gfx/table/default/'): self.wgt.setStyleSheet(str(common.loadStyleSheet('style.css'))) QDir.setCurrent('../../../../') self.slider = QSlider(Qt.Vertical) self.slider.setTickPosition(self.slider.TicksBelow) sliderLayout = QVBoxLayout() sliderLayout.addWidget(self.slider) sliderLayout.addWidget(self.edit) sliderhhL = QHBoxLayout() sliderhhL.addWidget(handhist) sliderhhL.addLayout(sliderLayout) mainView = QWidget() mainViewLayout = QVBoxLayout(mainView) #mainViewLayout.addWidget(handhist) mainViewLayout.addLayout(sliderhhL) #mainViewLayout.addLayout(sliderLayout) mainViewLayout.addWidget(self.wgt) mainPanelSplitter = QSplitter(self) #mainPanelSplitter.addWidget(QPushButton('Hello')) mainPanelSplitter.addWidget(playerNotesSplitter) mainPanelSplitter.addWidget(mainView) self.setCentralWidget(mainView) self.show() sb = handhist.verticalScrollBar() sb.setSliderPosition(sb.maximum())