fsmosca / Python-Easy-Chess-GUI

A Chess GUI based from Python using PySimpleGUI and Python-Chess.
GNU Lesser General Public License v3.0
161 stars 52 forks source link

Support for MacOS/Linux? #35

Closed fmhall closed 1 year ago

fmhall commented 4 years ago

Since .exes are used, this doesnt seem to work on UNIX based systems. What is involved in making that possible? I can submit a PR.

fsmosca commented 4 years ago

The source in python is available. Both python source and exe worked in windows. I have not tried it yet with linux or mac. Please submit a PR if you can.

fsmosca commented 4 years ago

Task is in progress.

tillchess commented 3 years ago

This small fix for OSX works to get engines directory filled with right content.

In get_engines add .DS_Store to the ignore list

def get_engines(self):
        """
        Get engine filenames [a.exe, b.exe, ...]

        :return: list of engine filenames
        """
        engine_list = []
        engine_path = Path('Engines')
        files = os.listdir(engine_path)

        for file in files:
            if not file.endswith('.gz') and not file.endswith('.dll') \
                    and not file.endswith('.DS_Store') \
                    and not file.endswith('.bin') \
                    and not file.endswith('.dat'):
                engine_list.append(file)

        return engine_list
fsmosca commented 3 years ago

Thanks I will update it.

fsmosca commented 3 years ago

This small fix for OSX works to get engines directory filled with right content.

In get_engines add .DS_Store to the ignore list

This is now implemented in Python Easy Chess GUI v1.13.

fsmosca commented 3 years ago

Task is in progress.

  • [x] Don't crash the program if there is no linux engine in Engines folder
  • [x] Able to run linux engine and get its id name
  • [ ] Fix window.Disable(), by PySimpleGUI library

This is the current fix to window.Disable(). Tested to work in windows and linux (WSL ubuntu 20.04). Might also work in osx. I don't have access to osx so I cannot test it.

Modify pysimplegui.py with the following change:

    def disable(self):
        """
        Disables window from taking any input from the user
        """
        if not self._is_window_created():
            return
        self.TKroot.grab_release()  # Only 'disables' an already 'enabled' window. Does nothing to a normal window
        # self.TKroot.attributes('-disabled', 1)
        # self.TKroot.grab_set_global()

    def enable(self):
        """
        Re-enables window to take user input after having it be Disabled previously
        """
        if not self._is_window_created():
            return
        self.TKroot.grab_set  # I read grab_set_global messes with all open windows so I wanted to avoid that
        # self.TKroot.attributes('-disabled', 0)
        # self.TKroot.grab_release()

This is not yet officially supported by pysimplegui.

Pichetraful commented 2 years ago

Recently installed this on Ubuntu 20.04 and when I want to select engine it closes down. It happens the same for all the other menu options but for game and help. I have re downloaded it but still the same error. Any other fix available?

fsmosca commented 2 years ago

Could you post the log file?. Let us see what is in there.

Pichetraful commented 2 years ago

These are the lines I see in the pecg_log.txt file. Is there other log or place where this will be registered: 2022-11-03 12:21:29,050 :: get_default_engine_opponent :: line: 2554 :: WARNING :: list index out of range 2022-11-03 12:21:29,050 :: set_default_adviser_engine :: line: 2543 :: WARNING : : list index out of range

fsmosca commented 2 years ago

There is no other log.

Looks like there is no engine. Check the Engines folder, there should be a linux engine there.

Pichetraful commented 2 years ago

Engines ls CDrill_1800_32bit.exe Deuterium_v2019.2.37.73_64bit_pop.exe Deuterium_v2019.1.36.50_32bit.exe Deuterium_v2020.1.38.5_linux_64bit ➜ Engines tree . ├── CDrill_1800_32bit.exe ├── Deuterium_v2019.1.36.50_32bit.exe ├── Deuterium_v2019.2.37.73_64bit_pop.exe └── Deuterium_v2020.1.38.5_linux_64bit

0 directories, 4 files

Pichetraful commented 2 years ago

how can I hardcode the engine? If I try to select/install from the menu, it crashes ....

fsmosca commented 2 years ago

Did you use PySimpleGUI==4.49.0?

Pichetraful commented 2 years ago

Checking....

Pichetraful commented 2 years ago

➜ Python-Easy-Chess-GUI-master pip list | grep PySimpleGUI PySimpleGUI 4.60.4

fsmosca commented 2 years ago

When I tried it last time, I only use 4.49.0

This is its requirements.txt

chess==1.6.1
pyperclip==1.8.2
PySimpleGUI==4.49.0
Romain-Revel commented 2 years ago

I confirm nothing works on Linux. I use Linux Mint 21 Cinnamon. python3

I need to install tkinter, else it spits an error: sudo apt-get install python3-tk

Even with the good dependecies, it has the same behavior: Play asks to install engine. Help shows the windows. Any other button crashes the window...

I tried both as root and user.

fsmosca commented 2 years ago

I will check this issue once I have a linux machine.

fsmosca commented 2 years ago

@Romain-Revel

Can you try this fix?

https://github.com/fsmosca/Python-Easy-Chess-GUI/issues/35#issuecomment-824499803

fsmosca commented 2 years ago

@Pichetraful

Can you try this fix?

https://github.com/fsmosca/Python-Easy-Chess-GUI/issues/35#issuecomment-824499803

Pichetraful commented 2 years ago

Where exactly should I place the code(fix)? I see many classes with different def's..... Would it be ok to place it in : class EasyChessGui: .....?

fsmosca commented 2 years ago

Ignore it. I updated the code to use HIde()/UnHide() instead of Disable()/Enable() in 41a4ae236dc0c8ba0644b8eb7cde7ad55acf8977

Based from test, it works on windows and linux/ubuntu.

Romain-Revel commented 2 years ago

It works.

But you should add in the install section the need to chmod +x the linux UCI engine, else it can't import name nor add it.

Pichetraful commented 1 year ago

@fsmosca, so... should I download the code again or what exactly do I need to do?

fsmosca commented 1 year ago

@fsmosca, so... should I download the code again or what exactly do I need to do?

Download the code again.

For example you can use the git clone command.

git clone https://github.com/fsmosca/Python-Easy-Chess-GUI.git
fsmosca commented 1 year ago

It works.

But you should add in the install section the need to chmod +x the linux UCI engine, else it can't import name nor add it.

Thanks.

Pichetraful commented 1 year ago

I just tested on my ubuntu and it works.... Thanks!