/
MutilDragTest2.py
718 lines (576 loc) · 23.9 KB
/
MutilDragTest2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
import sys, random
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QTreeView, QFileSystemModel, QLineEdit, \
QLabel, QFrame, QTextEdit, QHBoxLayout, QGridLayout, QVBoxLayout, QMainWindow, QFontComboBox, QPlainTextEdit, QColorDialog
from PyQt5.QtGui import QFont, QColor
from PyQt5.QtCore import QRect, QPoint, pyqtSignal, QObject
from Tile import RummyTile
class multiDrag(QObject):
multiDragStartSig = pyqtSignal()
multiDropSig = pyqtSignal()
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# TILE
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class DragLabel(QLabel):
def __init__(self, color, text, parent):
super(DragLabel, self).__init__(parent)
widthText = "13"
tileFont = QFont("DejaVu Sans Mono", 12)
self.setFont(tileFont)
metric = QtGui.QFontMetrics(self.font())
size = metric.size(QtCore.Qt.TextSingleLine, widthText)
# image = QtGui.QImage(size.width() + 12, size.height() + 22,
# QtGui.QImage.Format_ARGB32_Premultiplied)
image = QtGui.QImage(28, 39, QtGui.QImage.Format_ARGB32_Premultiplied)
# image = QtGui.QImage(self.width, self.height, 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.setBrush(QtCore.Qt.lightGray)
painter.setPen(QtCore.Qt.black)
painter.setRenderHint(QtGui.QPainter.Antialiasing)
# painter.setBrush(QtCore.Qt.white)
# painter.setBrush(QColor('#FFFFCC'))
painter.drawRoundedRect(QtCore.QRectF(0.5, 0.5, image.width() - 1,
image.height() - 4), 3, 3, QtCore.Qt.RelativeSize)
painter.setFont(tileFont)
# painter.setPen(QtCore.Qt.blue)
painter.drawText(QRect(QPoint(4, 3), size), QtCore.Qt.AlignCenter, text)
painter.end()
self.setPixmap(QtGui.QPixmap.fromImage(image))
self.labelText = text
class RummyTile(QWidget):
dragTile = None
mdrag = multiDrag()
def __init__(self, color, value, index):
super(RummyTile, self).__init__()
self.tileLabel = DragLabel(color, str(value), self)
self.color = color
self.value = value
self.owner = "none"
self.setObjectName("rummyTile")
self.MasterIndex = index
self.labelText = "hello world"
self.cellListIndex = 0
# RummyTile.mdrag.multiDragStartSig.connect(self.handleStartMultiDrag)
def setDragTile(self, val):
RummyTile.dragTile = val
# def getDragTile():
# return RummyTile.dragTile
def handleStartMultiDrag(self):
if self.parent():
if self.parent() in self.parent().getMultiDragList():
print("Start multi drag at ", str(self.parent().getPosition()))
def mouseMoveEvent(self, event):
print("Mouse move")
RummyTile.mdrag.multiDragStartSig.emit()
self.setDragTile(self)
mimeData = QtCore.QMimeData()
mimeData.setText("hello world")
self.parent().setDragStartCell(self.parent())
# self.setParent(None)
drag = QtGui.QDrag(self)
drag.setMimeData(mimeData)
drag.setHotSpot(event.pos() - self.rect().topLeft())
drag.setPixmap(self.tileLabel.pixmap())
self.hide()
if drag.exec_(QtCore.Qt.MoveAction | QtCore.Qt.CopyAction, QtCore.Qt.CopyAction) == QtCore.Qt.MoveAction:
self.close()
else:
self.show()
def getColor(self):
return self.color
def getValue(self):
return self.value
def setCellListIndex(self, listIndex):
self.cellListIndex = listIndex
def getCellListIndex(self, listIndex):
return self.cellListIndex
def setOwner(self, owner):
self.owner = owner
def __str__(self):
myStr = ""
if self.tileBag == []:
return "bag is empty"
else:
return "Here's the tile bag"
# for tile in self.tileBag:
# myStr += tile.getColor() + " " + str(tile.getValue()) + "\n"
# # return '<%s => %s>' % (self.__class__.__name__, self.name)
# return myStr
def getCellCol(cell):
print("getCellCol")
return cell.getCol()
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# CELL
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class BoardCell(QFrame):
dragStartCell = 0
multiDragList = []
mdrop = multiDrag()
def __init__(self, row, col, bgColor, fgColor):
super(BoardCell, self).__init__()
self.setFrameStyle(QFrame.Box)
self.layout = QVBoxLayout()
# self.layout.setContentsMargins(left, top, right, bottom)
self.layout.setContentsMargins(4, 4, 4, 4)
self.setLayout(self.layout)
self.setFixedHeight(48)
self.setFixedWidth(38)
self.row = row
self.col = col
self.left = None # the cell to the left of this one
self.right = None # the cell to the right of this one
self.bgColor = bgColor
self.fgColor = fgColor
self.pal = self.palette()
self.pal.setColor(self.backgroundRole(), QtCore.Qt.white)
self.pal.setColor(self.foregroundRole(), QtCore.Qt.black) # 6600cc
self.setPalette(self.pal)
self.setAutoFillBackground(True)
self.setMouseTracking(True)
self.setAcceptDrops(True)
self.highlightIsOn = False
BoardCell.mdrop.multiDropSig.connect(self.handleMultiDrop)
def setNeighbours(self, left, right):
self.left = left
self.right = right
def getMultiDragList(self):
return BoardCell.multiDragList
def getCol(self):
return self.col
def mouseReleaseEvent(self, a0: QtGui.QMouseEvent):
global getCellCol
if self.getResidentTileValue():
#This cell contains a tile so toggle the highlight
print("cell Mouse press")
if self.highlightIsOn:
self.highlightOff()
BoardCell.multiDragList.remove(self)
print("Remove from multi drag list ", str(self.getPosition()))
else:
self.hightlightOn()
BoardCell.multiDragList.append(self)
print("Add to multi drag list ", str(self.getPosition()))
return
else:
#This cell does not contain a tile so we may want to move highlighted tiles here
#first sort the multi drop list by column
BoardCell.multiDragList.sort(key=getCellCol)
BoardCell.multiDragList.reverse()
# getCellCol(self)
if len(BoardCell.multiDragList) > 0:
cell = BoardCell.multiDragList.pop()
tile = cell.getResidentTile()
cell.removeTile()
self.addTile(tile)
cell.highlightOff()
if len(BoardCell.multiDragList) > 0 and self.right:
self.right.handleMultiDrop()
def handleMultiDrop(self):
if BoardCell.multiDragList == []:
return
else:
cell = BoardCell.multiDragList.pop()
tile = cell.getResidentTile()
cell.removeTile()
self.addTile(tile)
cell.highlightOff()
if len(BoardCell.multiDragList) > 0 and self.right:
self.right.handleMultiDrop()
def setDragStartCell(self, cell):
BoardCell.dragStartCell = cell
def getDragStartCell(self):
return BoardCell.dragStartCell
def enterEvent(self, a0: QtCore.QEvent):
# print("Mouse entered", self.row, self.col)
self.getCellStatus()
return
def addTile(self, newTile):
print("Cell ", str(self.row), str(self.col), " add tile ", str(newTile.getColor()), " ",
str(newTile.getValue()))
newTile.show()
self.layout.addWidget(newTile)
def getResidentTileValue(self):
residentCell = self.findChild(RummyTile)
if residentCell != None:
print("Found resident tile at cell ", str(self.row), str(self.col), str(residentCell.getColor()), " ",
str(residentCell.getValue()))
return residentCell
else:
print("No resident tile at cell ", str(self.row), str(self.col))
return
def getResidentTile(self):
residentCell = self.findChild(RummyTile)
return residentCell
def removeTile(self):
print("Remove tile in cell ", str(self.row), str(self.col))
cellContents = self.findChild(RummyTile)
if cellContents != None:
cellContents.setParent(None)
def setBackgroundColor(self, color):
self.pal.setColor(self.backgroundRole(), QColor(color))
self.setPalette(self.pal)
def hightlightOn(self):
self.setBackgroundColor(QColor('#FF9999'))
self.highlightIsOn = True
def highlightOff(self):
self.setBackgroundColor(self.bgColor)
self.highlightIsOn = False
def setForegroundColor(self, color):
self.pal.setColor(self.foregroundRole(), QColor(color))
self.setPalette(self.pal)
def getCellStatus(self):
cellContents = self.findChild(RummyTile)
if cellContents == None:
# print("Cell Status: cell ", str(self.row), str(self.col), " is empty")
return "Empty"
else:
# print("Cell Status:-", str(self.row), str(self.col), " contains ", cellContents.color, cellContents.value)
return cellContents.color, cellContents.value
def getPosition(self):
return self.row, self.col
def dragEnterEvent(self, event):
if event.mimeData().hasFormat('application/x-fridgemagnet'):
if event.source() in self.children():
event.setDropAction(QtCore.Qt.MoveAction)
event.accept()
else:
event.acceptProposedAction()
elif event.mimeData().hasText():
event.acceptProposedAction()
else:
event.ignore()
dragMoveEvent = dragEnterEvent
def dropEvent(self, event):
BoardCell.mdrop.multiDropSig.emit()
if self.getDragStartCell().getPosition() == self.getPosition():
print("Drag start and end position was the same - toggle highlight")
if self.highlightIsOn:
self.highlightOff()
else:
self.hightlightOn()
return
if self.getDragStartCell().highlightIsOn:
self.getDragStartCell().highlightOff()
if event.mimeData().hasFormat('text/plain'):
mime = event.mimeData()
sourceTile = RummyTile.dragTile
residentTile = self.getResidentTileValue()
self.getDragStartCell().removeTile()
if residentTile != None:
# the cell we are dropping onto already contains a tile. So we want to put this tile into
# the cell where the drag started. Thereby swapping the tiles
self.removeTile()
self.getDragStartCell().addTile(residentTile)
self.addTile(sourceTile)
if event.source() in self.children():
event.setDropAction(QtCore.Qt.MoveAction)
event.accept()
else:
event.acceptProposedAction()
else:
event.ignore()
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# BOARD
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# ++++++++++++++++++++++++++++++++++++++++++++++
# CONTROL PANEL
# ++++++++++++++++++++++++++++++++++++++++++++++
class ControlPanel(QFrame):
def __init__(self):
super(ControlPanel, self).__init__()
self.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.layout = QVBoxLayout()
self.layout.setAlignment((QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop))
self.setLayout(self.layout)
self.setMinimumHeight(50)
self.setMinimumWidth(200)
self.buttonBar = QVBoxLayout()
# ++++++++++++++++++++++++++++++++++++++++++++++++
# Create buttons
# ++++++++++++++++++++++++++++++++++++++++++++++++
self.addTileButton = QPushButton("Take Tile")
self.addTileButton.clicked.connect(self.takeTile)
self.ExitButton = QPushButton("Exit")
self.ExitButton.clicked.connect(self.Exit)
self.ListBoardButton = QPushButton("List Board")
self.ListBoardButton.clicked.connect(self.listBoard)
self.MasterListButton = QPushButton("Master Tile List")
self.MasterListButton.clicked.connect(self.masterTileList)
self.buttonBar.addWidget(self.addTileButton)
self.buttonBar.addWidget(self.ExitButton)
# self.buttonBar.addWidget(self.ListBoardButton)
# self.buttonBar.addWidget(self.MasterListButton)
self.layout.addLayout(self.buttonBar)
self.infoBar = QVBoxLayout()
self.layout.setAlignment((QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop))
# ++++++++++++++++++++++++++++++++++++++++++++++++
# Create info box
# ++++++++++++++++++++++++++++++++++++++++++++++++
self.tilesLeftInfoBox = QPlainTextEdit()
tileLeftFont = QFont("Consolas", 10)
self.tilesLeftInfoBox.setFont(tileLeftFont)
self.tilesLeftInfoBox.setPlainText("All tiles in bag")
self.infoBar.addWidget(self.tilesLeftInfoBox)
self.layout.addLayout(self.infoBar)
def masterTileList(self):
tileCollection.printTileList()
def listBoard(self):
self.tilesLeftInfoBox.clear()
for cell in gameBoard.cellList:
index = cell.getCellListIndex()
cellStr = str(index) + " - " + str(cell.getCellStatus())
self.tilesLeftInfoBox.appendPlainText(cellStr)
def takeTile(self):
print("Taking a tile")
if tileBag.getNoOfTilesInBag() > 0:
nextTile = tileBag.getTileFromBag()
gameBoard.AddTileFromBag(nextTile)
def Exit(self):
print("Exiting....")
sys.exit()
def setNumberOfTiles(self, NoOfTiles):
tempStr = str(NoOfTiles) + " tiles left in bag"
self.tilesLeftInfoBox.setPlainText(tempStr)
def ChangeBackgroundColor(self):
color = QColorDialog.getColor(QColor('#888844'))
gameBoard.setBackgroundColor(color)
def ChangeForegroundColor(self):
color = QColorDialog.getColor()
gameBoard.setForegroundColor(color)
def clearInfoBox(self):
self.tilesLeftInfoBox.clear()
def appendInfo(self, tempStr):
self.tilesLeftInfoBox.appendPlainText(tempStr)
# ++++++++++++++++++++++++++++++++++++++++++++++
# BOARD
# ++++++++++++++++++++++++++++++++++++++++++++++
class TileGridBaseClass(QFrame):
def __init__(self, rows, cols, bgColor, fgColor):
super(TileGridBaseClass, self).__init__()
self.setFrameStyle(QFrame.Panel | QFrame.Sunken)
self.tileGrid = QGridLayout()
self.tileGrid.setHorizontalSpacing(0)
self.tileGrid.setVerticalSpacing(0)
self.rows = rows
self.cols = cols
self.cellList = []
self.pal = self.palette()
self.pal.setColor(self.backgroundRole(), bgColor)
self.pal.setColor(self.foregroundRole(), fgColor)
self.setPalette(self.pal)
self.setAutoFillBackground(True)
# Create all the cells
for row in range(self.rows):
for col in range(self.cols):
newCell = BoardCell(row, col, bgColor, fgColor)
self.tileGrid.addWidget(newCell, row, col) # i=row j=col
self.cellList.append(newCell)
self.setLayout(self.tileGrid)
# tell each cell who it's neighbours are
for n in range(len(self.cellList)):
cell = self.cellList[n]
(row, col) = cell.getPosition()
if col == 0:
left = None
right = self.cellList[n+1]
print("Cell ", str(row), " ", str(col), " has neighbours ", "None", " and ", str(right.getPosition()))
elif col == self.cols - 1:
left = self.cellList[n - 1]
right = None
print("Cell ", str(row), " ", str(col), " has neighbours ", str(left.getPosition()), " and ", "None")
else:
left = self.cellList[n - 1]
right = self.cellList[n + 1]
print("Cell ", str(row), " ", str(col), " has neighbours ", str(left.getPosition()), " and ",
str(right.getPosition()))
cell.setNeighbours(left, right)
def setBackgroundColor(self, color):
self.pal.setColor(self.backgroundRole(), QColor(color))
self.setPalette(self.pal)
for cell in self.cellList:
cell.setBackgroundColor(color)
def setForegroundColor(self, color):
self.pal.setColor(self.foregroundRole(), QColor(color))
self.setPalette(self.pal)
for cell in self.cellList:
cell.setForegroundColor(color)
def removeAllTiles(self):
print("Remove all tiles from the board")
for cell in self.cellList:
cell.removeTile()
class GameBoard(TileGridBaseClass):
def __init__(self, bgColor, fgColor):
super(GameBoard, self).__init__(5, 5, bgColor, fgColor)
self.listItems()
def listItems(self):
print("List grid contents")
cellsList = self.findChildren(BoardCell)
for cell in cellsList:
print(cell.row, cell.col)
def AddTileFromBag(self, tile):
print("AddTileFromBag")
# take a tile from the bag and put it in the
# next empty cell
# go through the cell list calling getStatus(). The first
# cell that returns empty is the one to add the tile to
for cell in self.cellList:
status = cell.getCellStatus()
if status == "Empty":
# cellIndex = cell.getCellListIndex()
# tile.setCellListIndex(cellIndex)
cell.addTile(tile)
break
def GetNextEmptyCellPosition(self):
print("GetNextEmptyCellPosition")
def removeTile(self, index):
self.cellList[index].removeTile()
class PlayerGrid(TileGridBaseClass):
def __init__(self, bgColor, fgColor):
super(PlayerGrid, self).__init__(2, 28, bgColor, fgColor)
self.pal = self.palette()
self.pal.setColor(self.backgroundRole(), bgColor)
self.pal.setColor(self.foregroundRole(), fgColor) # 6600cc
self.setPalette(self.pal)
self.setAutoFillBackground(True)
def newDeal(self):
global tileBag, player1Controls
for n in range(14):
if tileBag.getNoOfTilesInBag() > 0:
nextTile = tileBag.getTileFromBag()
print(player1Controls.getPlayerName(), " takes a tile. It's ", str(nextTile.getColor()), str(nextTile.getValue()))
for cell in self.cellList:
status = cell.getCellStatus()
if status == "Empty":
cell.addTile(nextTile)
break
else:
print("Whoops - tile bag is empty")
break
class TileBag():
def __init__(self):
self.tileBag = []
self.nextTileToDeal = 0
tile = tileCollection.getTile()
while tile != []:
tile.owner = "bag"
self.tileBag.append(tile)
tile = tileCollection.getTile()
random.shuffle(self.tileBag)
print("finished filling tile bag")
def getTileFromBag(self):
if self.tileBag == []:
return "empty"
else:
tile = self.tileBag.pop()
tile.owner = "board"
# controlPanel.setNumberOfTiles(len(self.tileBag) - 1)
return tile
def getNoOfTilesInBag(self):
return len(self.tileBag) - 1
def newGame(self):
self.tileBag = []
self.nextTileToDeal = 0
tile = tileCollection.getTile()
while tile != []:
tile.owner = "bag"
self.tileBag.append(tile)
tile = tileCollection.getTile()
random.shuffle(self.tileBag)
print("finished filling tile bag")
print("Shake the tile bag")
random.shuffle(self.tileBag)
class TileCollection():
def __init__(self):
self.tiles = []
index = 0
for tileVal in range(10):
self.tiles.append(RummyTile("black", tileVal, index))
index += 1
def getTile(self):
if self.tiles == []:
return []
else:
for tile in self.tiles:
if tile.owner == "none":
return tile
break
return []
def getTileAtIndex(self, index):
if index >= len(self.tiles):
print("ERROR: getTileAtIndex was asked for the tile at index ", str(index), " which is out of range")
return
else:
return self.tiles[index]
def printTileList(self):
# controlPanel.clearInfoBox()
for tile in self.tiles:
fred1 = str(tile.MasterIndex)
fred2 = str(tile.color)
fred3 = str(tile.value)
fred4 = str(tile.owner)
cellStr = fred1 + " - " + fred2 + " " + fred3 + " owner = " + fred4
# controlPanel.appendInfo(cellStr)
def clearTiles(self):
for tile in self.tiles:
tile.owner = "none"
class MainWin(QMainWindow):
def __init__(self):
super(MainWin, self).__init__()
self.controlPanel = ControlPanel()
# ++++++++++++++++++++++++++++++++++++++++++++++++
# Add everything to the grid layout
# ++++++++++++++++++++++++++++++++++++++++++++++++
self.gameLayout = QGridLayout()
self.gameLayout.addWidget(gameBoard, 1, 0, 3, 1)
self.gameLayout.addWidget(self.controlPanel, 1, 1, 3 ,1)
self.mainWidget = QWidget()
self.mainWidget.setLayout(self.gameLayout)
self.setCentralWidget(self.mainWidget)
# self.setGeometry(200, 200, 850, 500)
class FontSelector(QWidget):
def __init__(self):
super(FontSelector, self).__init__()
self.frame = QFrame()
self.frame.setFrameShape(QFrame.Box)
self.frame.setFrameShadow(QFrame.Sunken)
self.horizontalLayout = QHBoxLayout(self.frame)
self.textBold = QPushButton(self.frame)
self.textBold.setMaximumSize(QtCore.QSize(25, 25))
self.textBold.setCheckable(True)
self.textBold.setText("B")
self.horizontalLayout.addWidget(self.textBold)
self.textItalic = QPushButton(self.frame)
self.textItalic.setMaximumSize(QtCore.QSize(25, 25))
self.textItalic.setCheckable(True)
self.textItalic.setText("I")
self.horizontalLayout.addWidget(self.textItalic)
self.textUnderline = QPushButton(self.frame)
self.textUnderline.setMaximumSize(QtCore.QSize(25, 25))
self.textUnderline.setCheckable(True)
self.textUnderline.setText("U")
self.horizontalLayout.addWidget(self.textUnderline)
self.fontComboBox = QFontComboBox(self.frame)
self.horizontalLayout.addWidget(self.fontComboBox)
self.setLayout(self.horizontalLayout)
if __name__ == "__main__":
app = QApplication(sys.argv)
playerBgColor = QColor('#EBFFEB')
playerFgColor = QColor('#AAFF99')
boardBgColor = QColor('#F2F2F2')
boardFgColor = QColor('#FFCC00')
# player1Grid = PlayerGrid(playerBgColor, playerFgColor)
# player1Controls = PlayerControls(playerBgColor, playerFgColor, player1Grid, "Player 1")
#
# player2Grid = PlayerGrid(playerBgColor, playerFgColor)
# player1Controls = PlayerControls(playerBgColor, playerFgColor, player1Grid, "Player 2")
gameBoard = GameBoard(boardBgColor, boardFgColor)
tileCollection = TileCollection()
tileBag = TileBag()
RummyKub = MainWin()
RummyKub.show()
# newGame()
sys.exit(app.exec_())