Skip to content

Commit

Permalink
Merge pull request #34 from royerlab/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
royerloic authored Mar 8, 2024
2 parents f1f5cb3 + df36b05 commit 7428639
Show file tree
Hide file tree
Showing 130 changed files with 5,714 additions and 315 deletions.
Binary file added art/OmegaLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/OmegaLogoIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{% set name = "napari-chatgpt" %}
{% set version = "2024.2.19" %}

package:
name: {{ name|lower }}
version: {{ version }}

source:
url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/napari-chatgpt-{{ version }}.tar.gz
sha256: 4b7238d46766db40fff48735028ff17cd4229f1028a212646f381d459ab89625

build:
noarch: python
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation
number: 0

requirements:
host:
- python >=3.9
- setuptools >=42.0.0
- wheel
- setuptools-scm
- pip
run:
- python >=3.9
- numpy
- magicgui
- scikit-image
- qtpy
- qtawesome
- langchain ==0.1.5
- langchain-openai ==0.0.5
- openai
- anthropic
- fastapi
- uvicorn
- websockets
- tiktoken
- wikipedia
- lxml
- gtts
- playsound
- matplotlib-base
- xarray
- arbol
- microsoft::playwright
- duckduckgo-search
- ome-zarr
- transformers
- cryptography
- tabulate
- numba
- imageio
- notebook
- nbformat
- jedi
- black

#test:
# imports:
# - napari_chatgpt
# commands:
# - pip check
# requires:
# - pip

about:
home: https://github.com/royerlab/napari-chatgpt
summary: A napari plugin to process and analyse images with chatGPT.
license: BSD-3-Clause
license_file: LICENSE

extra:
recipe-maintainers:
- royerloic
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = napari-chatgpt
version = v2024.2.4
version = v2024.2.24
description = A napari plugin to process and analyse images with chatGPT.
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down Expand Up @@ -35,6 +35,7 @@ install_requires =
magicgui
scikit-image
qtpy
QtAwesome
langchain==0.1.5
langchain-openai==0.0.5
openai
Expand All @@ -60,6 +61,8 @@ install_requires =
imageio[ffmpeg,pyav]
notebook
nbformat
jedi
black


python_requires = >=3.9
Expand Down
Empty file added src/microplugin/__init__.py
Empty file.
1 change: 1 addition & 0 deletions src/microplugin/code_editor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# hello
100 changes: 100 additions & 0 deletions src/microplugin/code_editor/clickable_icon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
from typing import Union

from qtpy.QtCore import Qt, Signal
from qtpy.QtGui import QIcon, QPixmap, QColor, QImage
from qtpy.QtWidgets import QLabel


class ClickableIcon(QLabel):
clicked = Signal() # Signal to emit when the label is clicked

def __init__(
self,
icon: Union[QIcon, QPixmap, str],
size: int = 24,
invert_colors: bool = True,
parent=None
):
"""
Create a clickable icon label.
The icon can be: QIcon, QPixmap, or a string with the path to the image.
For example:
icon = QApplication.style().standardIcon(QStyle.SP_FileIcon)
Parameters
----------
icon : QIcon, QPixmap, or str
The icon to display
parent : QWidget, optional
The parent widget, by default None
"""
super().__init__(parent)

# Store the size for use in scaling the icon:
self.size = size

# Convert the icon to QIcon if it is a string:
if isinstance(icon, str):
icon = QIcon(icon)

# Convert the icon to QPixmap if it is a QIcon or use it directly if it's already a QPixmap:
if isinstance(icon, QIcon):
# Get the pixmap from the icon, scaled isotropically:
pixmap = icon.pixmap(self.size, self.size)
elif isinstance(icon, QPixmap):
pixmap = icon.scaled(self.size,
self.size,
Qt.KeepAspectRatio,
Qt.SmoothTransformation)

# Invert colors if requested:
if invert_colors:
pixmap = self._modify_pixmap_for_dark_ui(pixmap)

# If the icon is a QPixmap, use it directly:
self.setPixmap(pixmap)

# Change cursor to hand pointer when hovering over the label:
self.setCursor(Qt.PointingHandCursor)

def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self.clicked.emit()

@staticmethod
def _modify_pixmap_for_dark_ui(pixmap):
# Convert QPixmap to QImage
image = pixmap.toImage()

# Ensure image supports alpha channel:
image = image.convertToFormat(QImage.Format_ARGB32)

# Access image pixels to invert colors and rotate hue, preserving transparency
for x in range(image.width()):
for y in range(image.height()):
# Get the current pixel's color with alpha channel
color = QColor(image.pixel(x, y))

# Invert colors
color.setRed(255 - color.red())
color.setGreen(255 - color.green())
color.setBlue(255 - color.blue())

# # Rotate hue by 180 degrees
# if (
# color.hue() != -1
# ): # Check if color is not grayscale (hue is undefined for grayscale)
# hue = (color.hue() + 180) % 360
# color.setHsv(
# hue, color.saturation(), color.value(), color.alpha()
# ) # Preserve alpha
#
# # Set the modified color back to the image
# image.setPixel(
# x, y, color.rgba()
# ) # Use rgba() to include the alpha channel

# Convert QImage back to QPixmap
modified_pixmap = QPixmap.fromImage(image)
return modified_pixmap
Loading

0 comments on commit 7428639

Please sign in to comment.