Skip to content

Commit

Permalink
add pyinstall main spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
dickreuter committed Dec 30, 2023
1 parent 7369fa3 commit 3dc3f24
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 30 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -50,7 +50,6 @@ MANIFEST
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
Expand Down
38 changes: 38 additions & 0 deletions main.spec
@@ -0,0 +1,38 @@
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['main.py'],
pathex=['poker'],
datas=[ ( 'gui/ui/*.ui', '.' ),( 'gui/ui/*.ui', 'gui/ui' ),( 'decisionmaker/*.json', 'decisionmaker' )],
binaries=[],
hiddenimports=['pkg_resources.py2_warn', 'fastapi'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
icon='icon.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main')
50 changes: 50 additions & 0 deletions poker/main.spec
@@ -0,0 +1,50 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main',
)
83 changes: 83 additions & 0 deletions website/src/components/TableData.tsx
@@ -0,0 +1,83 @@
import React, { useState, useEffect } from 'react';

function DataTable({ data }) {
const [filteredData, setFilteredData] = useState(data);
const [searchTerm, setSearchTerm] = useState("");
const [sortConfig, setSortConfig] = useState({ key: null, direction: 'asc' });

useEffect(() => {
let resultData = [...data];

// Filter logic
if (searchTerm) {
resultData = resultData.filter(row =>
Object.values(row).some(value =>
String(value).toLowerCase().includes(searchTerm.toLowerCase())
)
);
}

// Sort logic
if (sortConfig.key) {
const directionMultiplier = sortConfig.direction === 'asc' ? 1 : -1;
resultData.sort((a, b) => {
if (a[sortConfig.key] < b[sortConfig.key]) {
return -1 * directionMultiplier;
}
if (a[sortConfig.key] > b[sortConfig.key]) {
return 1 * directionMultiplier;
}
return 0;
});
}

setFilteredData(resultData);
}, [searchTerm, sortConfig, data]);

const toggleSort = (key) => {
let direction = 'asc';
if (sortConfig.key === key && sortConfig.direction === 'asc') {
direction = 'desc';
}
setSortConfig({ key, direction });
}

return (
<div>
{/* Search input */}
{/* <input
type="text"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
placeholder="Filter table..."
/> */}
<div className="h4">
Worst Hands
</div>
<table>
<thead>
<tr>
{data.length > 0 && Object.keys(data[0]).map((key) => (
<th key={key} onClick={() => toggleSort(key)}>
{key} {sortConfig.key === key ? (sortConfig.direction === 'asc' ? '🔼' : '🔽') : ''}
</th>
))}
</tr>
</thead>
<tbody>
{filteredData.map((row, index) => (
<tr key={index}>
{Object.entries(row).map(([key, value], idx) => (
<td key={idx}>
{key === 'Loss' ? value.toFixed(2) : value}
</td>
))}
</tr>
))}
</tbody>
</table>
</div>
);
}

export default DataTable;
105 changes: 76 additions & 29 deletions website/src/views/TableMapper.tsx
@@ -1,10 +1,9 @@
import { Tab, Tabs } from "@mui/material";
import axios from "axios";
import "bootstrap/dist/css/bootstrap.css";
import { useEffect, useRef, useState } from "react";
import React, { useEffect, useRef, useState } from "react";
import { Dropdown } from "react-bootstrap";
import "./TableMapper.css";
import React from "react";

function TableMapper() {
const API_URL =
Expand Down Expand Up @@ -41,6 +40,34 @@ function TableMapper() {
"K",
"A",
];
const [buttonImages, setButtonImages] = useState({});
const [buttonSelections, setButtonSelections] = useState({});

// Add this function to handle the saving of button selections
const saveButtonSelection = async (imageData, label) => {
try {
// Here you would send imageData and label to your backend
const response = await axios.post(`${API_URL}/save_button_selection`, {
image_data: imageData,
label: label,
});
console.log("Button selection saved:", response.data);
} catch (error) {
console.error("Error saving button selection:", error);
}
};

// Call this function when the 'save' button is clicked
const onSaveButtonClick = (buttonKey) => {
const selection = buttonSelections[buttonKey];
const image = buttonImages[buttonKey];
if (selection && image) {
saveButtonSelection(image, buttonKey);
} else {
console.error("No selection or image to save for button:", buttonKey);
}
};

const takeScreenshot = async () => {
try {
console.log("taking screenshot");
Expand Down Expand Up @@ -76,7 +103,6 @@ function TableMapper() {
console.error("Error saving selection:", error);
}
};


const fetchAvailableTables = async () => {
try {
Expand Down Expand Up @@ -367,34 +393,55 @@ function TableMapper() {
<Tab label="Test" />
</Tabs>

{tabValue === 0 && <div>{/* Content for "Buttons" tab */}</div>}
{tabValue === 0 && (
<div className="buttons-grid">
{/* Map over your buttons data here */}
{Object.entries(buttonImages).map(
([buttonKey, imageSrc]) => (
<div key={buttonKey} className="button-image">
<img src={imageSrc} alt={buttonKey} />
<button
className="save-selection-button"
onClick={() => onSaveButtonClick(buttonKey)}
>
Save
</button>
</div>
)
)}
</div>
)}
{tabValue === 1 && <div>{/* Content for "Players" tab */}</div>}
{tabValue === 2 && (
<div className="cards-grid">
{ranks.map((rank) => (
<React.Fragment key={rank}>
{suits.map((suit) => {
const cardKey = rank + suit;
return (
<div key={cardKey} className="card-image">
{cardImages[cardKey] && (
<img src={cardImages[cardKey]} alt={cardKey} />
)}
<button
className="save-selection-button"
onClick={() => saveSelection(cardImages[cardKey], cardKey, lastSelectedTableName)}
>
Save
</button>
</div>
);
})}
</React.Fragment>
))}
</div>
)}
Create the saveSelection Function:

<div className="cards-grid">
{ranks.map((rank) => (
<React.Fragment key={rank}>
{suits.map((suit) => {
const cardKey = rank + suit;
return (
<div key={cardKey} className="card-image">
{cardImages[cardKey] && (
<img src={cardImages[cardKey]} alt={cardKey} />
)}
<button
className="save-selection-button"
onClick={() =>
saveSelection(
cardImages[cardKey],
cardKey,
lastSelectedTableName
)
}
>
Save
</button>
</div>
);
})}
</React.Fragment>
))}
</div>
)}

{tabValue === 3 && <div>{/* Content for "Mouse" tab */}</div>}
{tabValue === 4 && <div>{/* Content for "Test" tab */}</div>}
Expand Down

0 comments on commit 3dc3f24

Please sign in to comment.