Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Thursday, January 11, 2024

Install Qt Designer Standalone for pyqt5 python


Via command line

pip install pyqt5-tools

then run it
pyqt5-tools designer

usually its on for pyqt5-tools :
C:\python310\Scripts\pyqt5-tools.exe

and designer on this
C:\PYTHON_INSTALATION\Lib\site-packages\pyqt5_tools\Qt\bin

or
C:\PYTHON_INSTALATION\Lib\site-packages\qt5_applications\Qt\bin

Wednesday, September 30, 2020

Permutations php porting from python ( for fast and cheap cpu )

 taken from https://stackoverflow.com/questions/5506888/permutations-all-possible-sets-of-numbers

for my note

python https://docs.python.org/2/library/itertools.html#itertools.permutations



I've ported the Python itertools code listed here (using generators). The advantage over the solutions posted so far is that it allows you to specify r (permutation size).

function permutations($pool, $r = null) {
    $n = count($pool);

    if ($r == null) {
        $r = $n;
    }

    if ($r > $n) {
        return;
    }

    $indices = range(0, $n - 1);
    $cycles = range($n, $n - $r + 1, -1); // count down

    yield array_slice($pool, 0, $r);

    if ($n <= 0) {
        return;
    }

    while (true) {
        $exit_early = false;
        for ($i = $r;$i--;$i >= 0) {
            $cycles[$i]-= 1;
            if ($cycles[$i] == 0) {
                // Push whatever is at index $i to the end, move everything back
                if ($i < count($indices)) {
                    $removed = array_splice($indices, $i, 1);
                    array_push($indices, $removed[0]);
                }
                $cycles[$i] = $n - $i;
            } else {
                $j = $cycles[$i];
                // Swap indices $i & -$j.
                $i_val = $indices[$i];
                $neg_j_val = $indices[count($indices) - $j];
                $indices[$i] = $neg_j_val;
                $indices[count($indices) - $j] = $i_val;
                $result = [];
                $counter = 0;
                foreach ($indices as $indx) {
                    array_push($result, $pool[$indx]);
                    $counter++;
                    if ($counter == $r) break;
                }
                yield $result;
                $exit_early = true;
                break;
            }
        }
        if (!$exit_early) {
            break; // Outer while loop
        }
    }
}

It works for me, but no promises! Example usage:

$result = iterator_to_array(permutations([1, 2, 3, 4], 3));
foreach ($result as $row) {
    print implode(", ", $row) . "\n";
}

from https://stackoverflow.com/a/43307800/6125958



Monday, July 16, 2018

Qt Layout on QMainWindow ( work in pyqt as well )

 


 

Taken from https://stackoverflow.com/questions/1508939/qt-layout-on-qmainwindow as note

You don't have to create a QVBoxLayout manually. Just select your central QWidget and press a make-layout button
https://stackoverflow.com/a/1508954


Add at least one widget on your MainWindow. Then select your window by clicking on it and click on the VerticalLayout Button at the top of QTCreator. You Vertical Layout is automatically added to the central widget and fills all the surface.

https://stackoverflow.com/a/1508969


Tuesday, August 29, 2017

Upgrade PIP in windows using Powershell

Open powershell and paste this
pip list --outdated --format=freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}

Saturday, February 18, 2017

LittleNote of Python and pyqt

Convert ui to python ( python27 and pyqt4 )

 C:\Python27\Lib\site-packages\PyQt4\pyuic4.bat C:\Users\LENOVO\PycharmProjects\IgPoster\IgPoster.ui -o C:\Users\LENOVO\PycharmProjects\IgPoster\IgPoster.py

pyinstaller python27 with hook

 python27 "C:\Python27\PyInstaller-3.2.1\pyinstaller.py" --runtime-hook "C:\Users\LENOVO\PycharmProjects\IgPoster_v1.1\rthook_pyqt4.py" "C:\Users\LENOVO\PycharmProjects\IgPoster_v1.1\Login.py" --noconsole --onefile --icon=bg.ico

pyinstaller.py "C:\Users\LENOVO\PycharmProjects\IgPoster_v1.1\Login.py" --noconsole --onefile --icon=bg.ico

pyinstaller "C:\Users\LENOVO\PycharmProjects\IgPoster_v1.1\Login.py" --noconsole --onefile --icon=bg.ico

 

pyqt5 with python 3

C:\python37\Scripts\pyuic5.exe C:\Users\akura\PycharmProjects\text2SpeechGui\main.ui -o C:\Users\akura\PycharmProjects\text2SpeechGui\mainUI.py

C:\python37\Scripts\designer.exe