kandi background
Explore Kits

tips | Most commonly used git tips and tricks | Android library

 by   git-tips JavaScript Version: Current License: MIT

 by   git-tips JavaScript Version: Current License: MIT

Download this library from

kandi X-RAY | tips Summary

tips is a JavaScript library typically used in Mobile, Android, Unity, Docker applications. tips has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Most commonly used git tips and tricks.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • tips has a medium active ecosystem.
  • It has 19842 star(s) with 1677 fork(s). There are 599 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 13 open issues and 17 have been closed. On average issues are closed in 16 days. There are 10 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of tips is current.
tips Support
Best in #Android
Average in #Android
tips Support
Best in #Android
Average in #Android

quality kandi Quality

  • tips has 0 bugs and 0 code smells.
tips Quality
Best in #Android
Average in #Android
tips Quality
Best in #Android
Average in #Android

securitySecurity

  • tips has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • tips code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
tips Security
Best in #Android
Average in #Android
tips Security
Best in #Android
Average in #Android

license License

  • tips is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
tips License
Best in #Android
Average in #Android
tips License
Best in #Android
Average in #Android

buildReuse

  • tips releases are not available. You will need to build from source code and install.
  • Installation instructions are not available. Examples and code snippets are available.
tips Reuse
Best in #Android
Average in #Android
tips Reuse
Best in #Android
Average in #Android
Top functions reviewed by kandi - BETA

kandi has reviewed tips and discovered the below as its top functions. This is intended to give you an instant insight into tips implemented functionality, and help decide if they suit your requirements.

  • Escape and escape double quotes .

tips Key Features

Most commonly used git tips and tricks.

Everyday Git in twenty commands or so

copy iconCopydownload iconDownload
git help everyday

Show helpful guides that come with Git

copy iconCopydownload iconDownload
git help -g

Search change by content

copy iconCopydownload iconDownload
git log -S'<a term in the source>'

Show changes over time for specific file

copy iconCopydownload iconDownload
git log -p <file_name>

Remove sensitive data from history, after a push

copy iconCopydownload iconDownload
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <path-to-your-file>' --prune-empty --tag-name-filter cat -- --all && git push origin --force --all

Sync with remote, overwrite local changes

copy iconCopydownload iconDownload
git fetch origin && git reset --hard origin/master && git clean -f -d

List of all files till a commit

copy iconCopydownload iconDownload
git ls-tree --name-only -r <commit-ish>

Git reset first commit

copy iconCopydownload iconDownload
git update-ref -d HEAD

Reset: preserve uncommitted local changes

copy iconCopydownload iconDownload
git reset --keep <commit>

List all the conflicted files

copy iconCopydownload iconDownload
git diff --name-only --diff-filter=U

List of all files changed in a commit

copy iconCopydownload iconDownload
git diff-tree --no-commit-id --name-only -r <commit-ish>

Unstaged changes since last commit

copy iconCopydownload iconDownload
git diff

Changes staged for commit

copy iconCopydownload iconDownload
git diff --cached

Show both staged and unstaged changes

copy iconCopydownload iconDownload
git diff HEAD

List all branches that are already merged into master

copy iconCopydownload iconDownload
git branch --merged master

Quickly switch to the previous branch

copy iconCopydownload iconDownload
git checkout -

Remove branches that have already been merged with master

copy iconCopydownload iconDownload
git branch --merged master | grep -v '^\*' | xargs -n 1 git branch -d

List all branches and their upstreams, as well as last commit on branch

copy iconCopydownload iconDownload
git branch -vv

Track upstream branch

copy iconCopydownload iconDownload
git branch -u origin/mybranch

Delete local branch

copy iconCopydownload iconDownload
git branch -d <local_branchname>

Delete remote branch

copy iconCopydownload iconDownload
git push origin --delete <remote_branchname>

Create local tag

copy iconCopydownload iconDownload
git tag <tag-name>

Delete local tag

copy iconCopydownload iconDownload
git tag -d <tag-name>

Delete remote tag

copy iconCopydownload iconDownload
git push origin :refs/tags/<tag-name>

Undo local changes with the last content in head

copy iconCopydownload iconDownload
git checkout -- <file_name>

Revert: Undo a commit by creating a new commit

copy iconCopydownload iconDownload
git revert <commit-ish>

Reset: Discard commits, advised for private branch

copy iconCopydownload iconDownload
git reset <commit-ish>

Reword the previous commit message

copy iconCopydownload iconDownload
git commit -v --amend

See commit history for just the current branch

copy iconCopydownload iconDownload
git cherry -v master

Amend author.

copy iconCopydownload iconDownload
git commit --amend --author='Author Name <email@address.com>'

Reset author, after author has been changed in the global config.

copy iconCopydownload iconDownload
git commit --amend --reset-author --no-edit

Changing a remote's URL

copy iconCopydownload iconDownload
git remote set-url origin <URL>

Get list of all remote references

copy iconCopydownload iconDownload
git remote

Get list of all local and remote branches

copy iconCopydownload iconDownload
git branch -a

Get only remote branches

copy iconCopydownload iconDownload
git branch -r

Stage parts of a changed file, instead of the entire file

copy iconCopydownload iconDownload
git add -p

Get git bash completion

copy iconCopydownload iconDownload
curl -L http://git.io/vfhol > ~/.git-completion.bash && echo '[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash' >> ~/.bashrc

What changed since two weeks?

copy iconCopydownload iconDownload
git log --no-merges --raw --since='2 weeks ago'

See all commits made since forking from master

copy iconCopydownload iconDownload
git log --no-merges --stat --reverse master..

Pick commits across branches using cherry-pick

copy iconCopydownload iconDownload
git checkout <branch-name> && git cherry-pick <commit-ish>

Find out branches containing commit-hash

copy iconCopydownload iconDownload
git branch -a --contains <commit-ish>

Git Aliases

copy iconCopydownload iconDownload
git config --global alias.<handle> <command> 
git config --global alias.st status

Saving current state of tracked files without commiting

copy iconCopydownload iconDownload
git stash

Saving current state of unstaged changes to tracked files

copy iconCopydownload iconDownload
git stash -k

Saving current state including untracked files

copy iconCopydownload iconDownload
git stash -u

Saving current state with message

copy iconCopydownload iconDownload
git stash push -m <message>

Saving current state of all files (ignored, untracked, and tracked)

copy iconCopydownload iconDownload
git stash -a

Show list of all saved stashes

copy iconCopydownload iconDownload
git stash list

Show the contents of any stash in patch form

copy iconCopydownload iconDownload
git stash show -p <stash@{n}>

Apply any stash without deleting from the stashed list

copy iconCopydownload iconDownload
git stash apply <stash@{n}>

Apply last stashed state and delete it from stashed list

copy iconCopydownload iconDownload
git stash pop

Delete all stored stashes

copy iconCopydownload iconDownload
git stash clear

Grab a single file from a stash

copy iconCopydownload iconDownload
git checkout <stash@{n}> -- <file_path>

Show all tracked files

copy iconCopydownload iconDownload
git ls-files -t

Show all untracked files

copy iconCopydownload iconDownload
git ls-files --others

Show all ignored files

copy iconCopydownload iconDownload
git ls-files --others -i --exclude-standard

Create new working tree from a repository (git 2.5)

copy iconCopydownload iconDownload
git worktree add -b <branch-name> <path> <start-point>

Create new working tree from HEAD state

copy iconCopydownload iconDownload
git worktree add --detach <path> HEAD

Untrack files without deleting

copy iconCopydownload iconDownload
git rm --cached <file_path>

Before deleting untracked files/directory, do a dry run to get the list of these files/directories

copy iconCopydownload iconDownload
git clean -n

Forcefully remove untracked files

copy iconCopydownload iconDownload
git clean -f

Forcefully remove untracked directory

copy iconCopydownload iconDownload
git clean -f -d

Update all the submodules

copy iconCopydownload iconDownload
git submodule foreach git pull

Show all commits in the current branch yet to be merged to master

copy iconCopydownload iconDownload
git cherry -v master

Rename a branch

copy iconCopydownload iconDownload
git branch -m <new-branch-name>

Rebases 'feature' to 'master' and merges it in to master

copy iconCopydownload iconDownload
git rebase master feature && git checkout master && git merge -

Archive the

copy iconCopydownload iconDownload
git archive master --format=zip --output=master.zip

Modify previous commit without modifying the commit message

copy iconCopydownload iconDownload
git add --all && git commit --amend --no-edit

Prunes references to remove branches that have been deleted in the remote.

copy iconCopydownload iconDownload
git fetch -p

Delete local branches that has been squash and merged in the remote.

copy iconCopydownload iconDownload
git branch -vv | grep ': gone]' | awk '{print <!-- @doxie.inject start -->}' | xargs git branch -D

Retrieve the commit hash of the initial revision.

copy iconCopydownload iconDownload
 git rev-list --reverse HEAD | head -1

Visualize the version tree.

copy iconCopydownload iconDownload
git log --pretty=oneline --graph --decorate --all

Visualize the tree including commits that are only referenced from reflogs

copy iconCopydownload iconDownload
git log --graph --decorate --oneline $(git rev-list --walk-reflogs --all)

Deploying git tracked subfolder to gh-pages

copy iconCopydownload iconDownload
git subtree push --prefix subfolder_name origin gh-pages

Adding a project to repo using subtree

copy iconCopydownload iconDownload
git subtree add --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

Get latest changes in your repo for a linked project using subtree

copy iconCopydownload iconDownload
git subtree pull --prefix=<directory_name>/<project_name> --squash git@github.com:<username>/<project_name>.git master

Export a branch with history to a file.

copy iconCopydownload iconDownload
git bundle create <file> <branch-name>

Import from a bundle

copy iconCopydownload iconDownload
git clone repo.bundle <repo-dir> -b <branch-name>

Get the name of current branch.

copy iconCopydownload iconDownload
git rev-parse --abbrev-ref HEAD

Ignore one file on commit (e.g. Changelog).

copy iconCopydownload iconDownload
git update-index --assume-unchanged Changelog; git commit -a; git update-index --no-assume-unchanged Changelog

Stash changes before rebasing

copy iconCopydownload iconDownload
git rebase --autostash

Fetch pull request by ID to a local branch

copy iconCopydownload iconDownload
git fetch origin pull/<id>/head:<branch-name>

Show the most recent tag on the current branch.

copy iconCopydownload iconDownload
git describe --tags --abbrev=0

Show inline word diff.

copy iconCopydownload iconDownload
git diff --word-diff

Show changes using common diff tools.

copy iconCopydownload iconDownload
git difftool [-t <tool>] <commit1> <commit2> <path>

Don’t consider changes for tracked file.

copy iconCopydownload iconDownload
git update-index --assume-unchanged <file_name>

Undo assume-unchanged.

copy iconCopydownload iconDownload
git update-index --no-assume-unchanged <file_name>

Clean the files from

copy iconCopydownload iconDownload
git clean -X -f

Restore deleted file.

copy iconCopydownload iconDownload
git checkout <deleting_commit> -- <file_path>

Restore file to a specific commit-hash

copy iconCopydownload iconDownload
git checkout <commit-ish> -- <file_path>

Always rebase instead of merge on pull.

copy iconCopydownload iconDownload
git config --global pull.rebase true

List all the alias and configs.

copy iconCopydownload iconDownload
git config --list

Make git case sensitive.

copy iconCopydownload iconDownload
git config --global core.ignorecase false

Add custom editors.

copy iconCopydownload iconDownload
git config --global core.editor '$EDITOR'

Auto correct typos.

copy iconCopydownload iconDownload
git config --global help.autocorrect 1

Check if the change was a part of a release.

copy iconCopydownload iconDownload
git name-rev --name-only <SHA-1>

Dry run. (any command that supports dry-run flag should do.)

copy iconCopydownload iconDownload
git clean -fd --dry-run

Marks your commit as a fix of a previous commit.

copy iconCopydownload iconDownload
git commit --fixup <SHA-1>

Squash fixup commits normal commits.

copy iconCopydownload iconDownload
git rebase -i --autosquash

Skip staging area during commit.

copy iconCopydownload iconDownload
git commit --only <file_path>

Interactive staging.

copy iconCopydownload iconDownload
git add -i

List ignored files.

copy iconCopydownload iconDownload
git check-ignore *

Status of ignored files.

copy iconCopydownload iconDownload
git status --ignored

Commits in Branch1 that are not in Branch2

copy iconCopydownload iconDownload
git log Branch1 ^Branch2

List n last commits

copy iconCopydownload iconDownload
git log -<n>

Reuse recorded resolution, record and reuse previous conflicts resolutions.

copy iconCopydownload iconDownload
git config --global rerere.enabled 1

Open all conflicted files in an editor.

copy iconCopydownload iconDownload
git diff --name-only | uniq | xargs $EDITOR

Count unpacked number of objects and their disk consumption.

copy iconCopydownload iconDownload
git count-objects --human-readable

Prune all unreachable objects from the object database.

copy iconCopydownload iconDownload
git gc --prune=now --aggressive

Instantly browse your working repository in gitweb.

copy iconCopydownload iconDownload
git instaweb [--local] [--httpd=<httpd>] [--port=<port>] [--browser=<browser>]

View the GPG signatures in the commit log

copy iconCopydownload iconDownload
git log --show-signature

Remove entry in the global config.

copy iconCopydownload iconDownload
git config --global --unset <entry-name>

Checkout a new branch without any history

copy iconCopydownload iconDownload
git checkout --orphan <branch_name>

Extract file from another branch.

copy iconCopydownload iconDownload
git show <branch_name>:<file_name>

List only the root and merge commits.

copy iconCopydownload iconDownload
git log --first-parent

Change previous two commits with an interactive rebase.

copy iconCopydownload iconDownload
git rebase --interactive HEAD~2

List all branch is WIP

copy iconCopydownload iconDownload
git checkout master && git branch --no-merged

Find guilty with binary search

copy iconCopydownload iconDownload
git bisect start                    # Search start 
git bisect bad                      # Set point to bad commit 
git bisect good v2.6.13-rc2         # Set point to good commit|tag 
git bisect bad                      # Say current state is bad 
git bisect good                     # Say current state is good 
git bisect reset                    # Finish search 

Bypass pre-commit and commit-msg githooks

copy iconCopydownload iconDownload
git commit --no-verify

List commits and changes to a specific file (even through renaming)

copy iconCopydownload iconDownload
git log --follow -p -- <file_path>

Clone a single branch

copy iconCopydownload iconDownload
git clone -b <branch-name> --single-branch https://github.com/user/repo.git

Create and switch new branch

copy iconCopydownload iconDownload
git checkout -b <branch-name>

Ignore file mode changes on commits

copy iconCopydownload iconDownload
git config core.fileMode false

Turn off git colored terminal output

copy iconCopydownload iconDownload
git config --global color.ui false

Specific color settings

copy iconCopydownload iconDownload
git config --global <specific command e.g branch, diff> <true, false or always>

Show all local branches ordered by recent commits

copy iconCopydownload iconDownload
git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/

Find lines matching the pattern (regex or string) in tracked files

copy iconCopydownload iconDownload
git grep --heading --line-number 'foo bar'

Clone a shallow copy of a repository

copy iconCopydownload iconDownload
git clone https://github.com/user/repo.git --depth 1

Search Commit log across all branches for given text

copy iconCopydownload iconDownload
git log --all --grep='<given-text>'

Get first commit in a branch (from master)

copy iconCopydownload iconDownload
git log --oneline master..<branch-name> | tail -1

Unstaging Staged file

copy iconCopydownload iconDownload
git reset HEAD <file-name>

Force push to Remote Repository

copy iconCopydownload iconDownload
git push -f <remote-name> <branch-name>

Adding Remote name

copy iconCopydownload iconDownload
git remote add <remote-nickname> <remote-url>

List all currently configured remotes

copy iconCopydownload iconDownload
git remote -v

Show the author, time and last revision made to each line of a given file

copy iconCopydownload iconDownload
git blame <file-name>

Group commits by authors and title

copy iconCopydownload iconDownload
git shortlog

Forced push but still ensure you don't overwrite other's work

copy iconCopydownload iconDownload
git push --force-with-lease <remote-name> <branch-name>

Show how many lines does an author contribute

copy iconCopydownload iconDownload
git log --author='_Your_Name_Here_' --pretty=tformat: --numstat | gawk '{ add += <!-- @doxie.inject start -->; subs += <!-- @doxie.inject end -->; loc += <!-- @doxie.inject start --> - <!-- @doxie.inject end --> } END { printf "added lines: %s removed lines: %s total lines: %s
", add, subs, loc }' -

Revert: Reverting an entire merge

copy iconCopydownload iconDownload
git revert -m 1 <commit-ish>

Number of commits in a branch

copy iconCopydownload iconDownload
git rev-list --count <branch-name>

Alias: git undo

copy iconCopydownload iconDownload
git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'

Add object notes

copy iconCopydownload iconDownload
git notes add -m 'Note on the previous commit....'

Show all the git-notes

copy iconCopydownload iconDownload
git log --show-notes='*'

Apply commit from another repository

copy iconCopydownload iconDownload
git --git-dir=<source-dir>/.git format-patch -k -1 --stdout <SHA1> | git am -3 -k

Specific fetch reference

copy iconCopydownload iconDownload
git fetch origin master:refs/remotes/origin/mymaster

Find common ancestor of two branches

copy iconCopydownload iconDownload
git merge-base <branch-name> <other-branch-name>

List unpushed git commits

copy iconCopydownload iconDownload
git log --branches --not --remotes

Add everything, but whitespace changes

copy iconCopydownload iconDownload
git diff --ignore-all-space | git apply --cached

Edit [local/global] git config

copy iconCopydownload iconDownload
git config [--global] --edit

blame on certain range

copy iconCopydownload iconDownload
git blame -L <start>,<end>

Show a Git logical variable.

copy iconCopydownload iconDownload
git var -l | <variable>

Preformatted patch file.

copy iconCopydownload iconDownload
git format-patch -M upstream..topic

Get the repo name.

copy iconCopydownload iconDownload
git rev-parse --show-toplevel

logs between date range

copy iconCopydownload iconDownload
git log --since='FEB 1 2017' --until='FEB 14 2017'

Exclude author from logs

copy iconCopydownload iconDownload
git log --perl-regexp --author='^((?!excluded-author-regex).*)

Generates a summary of pending changes

copy iconCopydownload iconDownload
git request-pull v1.0 https://git.ko.xz/project master:for-linus

List references in a remote repository

copy iconCopydownload iconDownload
git ls-remote git://git.kernel.org/pub/scm/git/git.git

Backup untracked files.

copy iconCopydownload iconDownload
git ls-files --others -i --exclude-standard | xargs zip untracked.zip

List all git aliases

copy iconCopydownload iconDownload
git config -l | grep alias | sed 's/^alias\.//g'

Show git status short

copy iconCopydownload iconDownload
git status --short --branch

Checkout a commit prior to a day ago

copy iconCopydownload iconDownload
git checkout master@{yesterday}

Push the current branch to the same name on the remote repository

copy iconCopydownload iconDownload
git push origin HEAD

Push a new local branch to remote repository and track

copy iconCopydownload iconDownload
git push -u origin <branch_name>

Change a branch base

copy iconCopydownload iconDownload
git rebase --onto <new_base> <old_base>

Use SSH instead of HTTPs for remotes

copy iconCopydownload iconDownload
git config --global url.'git@github.com:'.insteadOf 'https://github.com/'

Update a submodule to the latest commit

copy iconCopydownload iconDownload
cd <path-to-submodule>
git pull origin <branch>
cd <root-of-your-main-project>
git add <path-to-submodule>
git commit -m "submodule updated"

Prevent auto replacing LF with CRLF

copy iconCopydownload iconDownload
git config --global core.autocrlf false

Align widget to bottom of sibling column

copy iconCopydownload iconDownload
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: Container(
        color: Colors.black12.withOpacity(0.1),
        padding: const EdgeInsets.all(24),
        child: Align(
          child: IntrinsicHeight(
            child: Row(
              children: [
                Container(
                  padding: const EdgeInsets.all(24),
                  color: Colors.green,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Container(
                        height: 500,
                        width: 200,
                        color: Colors.blue,
                      )
                    ],
                  ),
                ),
                Container(
                  padding: const EdgeInsets.all(24),
                  color: Colors.greenAccent,
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Container(
                        padding: const EdgeInsets.all(24),
                        height: 100,
                        width: 200,
                        color: Colors.yellow,
                      ),
                      const Spacer(),
                      Container(
                        padding: const EdgeInsets.all(24),
                        height: 100,
                        width: 200,
                        color: Colors.red,
                      ),
                    ],
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
-----------------------
 @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',

      home: Container(
        color: Colors.white,

        child: Row(
          children: [
            Flexible(child: Container(
              height: MediaQuery.of(context).size.height,
              padding: const EdgeInsets.all(24),
              color: Colors.green,
              child:  Container(
                height: 500,
                width: MediaQuery.of(context).size.width,
                color: Colors.blue,
              ),
            ),flex: 1,),
          const SizedBox(width: 2.0,),
          Flexible(child:   Container(
            height: MediaQuery.of(context).size.height,
            padding: const EdgeInsets.all(24),
            color: Colors.greenAccent,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  padding: const EdgeInsets.all(24),
                  height: 100,
                  width: 200,
                  color: Colors.yellow,
                ),
                Container(
                  padding: const EdgeInsets.all(24),
                  height: 50,
                  width: 200,
                  color: Colors.red,
                ),
              ],
            ),
          ),flex: 1,)
          ],
        ),
      ),
    );
  }

Next failed to load SWC binary

copy iconCopydownload iconDownload
{
swcMinify: false // it should be false by default 
}
{
"presets": ["next/babel"]
}
npm install next@canary
-----------------------
{
swcMinify: false // it should be false by default 
}
{
"presets": ["next/babel"]
}
npm install next@canary
-----------------------
{
swcMinify: false // it should be false by default 
}
{
"presets": ["next/babel"]
}
npm install next@canary
-----------------------
command- npx create-next-app 'your_project_name' --use-npm --example "https://github.com/vercel/next-learn/tree/master/basics/learn-starter"
-----------------------
{"presets": ["next/babel"]}
-----------------------

############### Base Image ###############
FROM node:14-buster-slim AS base
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .

############### Build Image ###############
FROM base AS build

ARG app_env=production
ARG app_port=3000

WORKDIR /build
COPY --from=base /app ./

ENV NODE_ENV=${app_env}
ENV PORT=${app_port}
EXPOSE ${app_port}

RUN npm run build

############### Deploy Image ###############
FROM node:14.18.1-alpine AS production

ARG app_env=production
ENV NODE_ENV=${app_env}
WORKDIR /app
COPY --from=build /build/package*.json ./
COPY --from=build /build/.next ./.next
COPY --from=build /build/public ./public
RUN npm install next

EXPOSE 3000
CMD npm run start

version: "3"

services:
  web-server:
    env_file:
      - ./.env
    build:
      context: .
      dockerfile: Dockerfile
      target: base
    command: npm run dev
    container_name: web-server
    restart: always
    volumes:
      - ./:/app
      - /app/node_modules
    ports:
      - "${NODEJS_PORT}:3000"
-----------------------

############### Base Image ###############
FROM node:14-buster-slim AS base
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .

############### Build Image ###############
FROM base AS build

ARG app_env=production
ARG app_port=3000

WORKDIR /build
COPY --from=base /app ./

ENV NODE_ENV=${app_env}
ENV PORT=${app_port}
EXPOSE ${app_port}

RUN npm run build

############### Deploy Image ###############
FROM node:14.18.1-alpine AS production

ARG app_env=production
ENV NODE_ENV=${app_env}
WORKDIR /app
COPY --from=build /build/package*.json ./
COPY --from=build /build/.next ./.next
COPY --from=build /build/public ./public
RUN npm install next

EXPOSE 3000
CMD npm run start

version: "3"

services:
  web-server:
    env_file:
      - ./.env
    build:
      context: .
      dockerfile: Dockerfile
      target: base
    command: npm run dev
    container_name: web-server
    restart: always
    volumes:
      - ./:/app
      - /app/node_modules
    ports:
      - "${NODEJS_PORT}:3000"
-----------------------
rm -rf node_modules && rm package-lock.json && npm i

Webpack-5 - Stop Webpack from processing root-relative paths to images in scss (or css)

copy iconCopydownload iconDownload
module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        loader: "css-loader",
        options: {
          url: {
            filter: (url, _resourcePath) => {
              // Disable processing for root-relative urls under /images
              return !/^\/images\//.test(url)

              // This would disable processing for all root-relative urls:
              // return !/^\//.test(url);
            },
          },
        },
      },
    ],
  },
};
module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        loader: "css-loader",
        options: {
          url: false,
        },
      },
    ],
  },
};
-----------------------
module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        loader: "css-loader",
        options: {
          url: {
            filter: (url, _resourcePath) => {
              // Disable processing for root-relative urls under /images
              return !/^\/images\//.test(url)

              // This would disable processing for all root-relative urls:
              // return !/^\//.test(url);
            },
          },
        },
      },
    ],
  },
};
module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        loader: "css-loader",
        options: {
          url: false,
        },
      },
    ],
  },
};

Azure, .Net, Cobertura - ##[warning]Multiple file or directory matches were found

copy iconCopydownload iconDownload
       - task: reportgenerator@4
         displayName: 'Merge code coverage reports'
         inputs:
           reports: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
           targetdir: '$(Pipeline.Workspace)/coverlet'
           reporttypes: 'Cobertura'
           verbosity: 'Verbose'
     
       - task: PublishCodeCoverageResults@1
         displayName: 'Publish code coverage results'
         inputs:
           codeCoverageTool: Cobertura
           summaryFileLocation: '$(Pipeline.Workspace)/coverlet/Cobertura.xml'

Compose: Place view between two backgrounds

copy iconCopydownload iconDownload
@Composable
fun CircleInsideBoxes() {
    Box(
        modifier = Modifier
            .fillMaxWidth()
            .height(200.dp) //your height for the container
    ) {
        Column(
            modifier = Modifier.fillMaxSize()
        ) {
            Box(
                modifier = Modifier
                    .fillMaxWidth()
                    .weight(1f)
                    .background(color = Color(0xFF3F48CC))
            )
            Box(
                modifier = Modifier
                    .fillMaxWidth()
                    .weight(1f)
                    .background(color = Color(0xFF00A2E8))
            )
        }
         //Outside column inside parent Box
         Box(
              modifier = Modifier
                 .clip(CircleShape)
                 .background(color = Color(0xFFED1C24))
                 .size(80.dp) //your size for the circle
                 .align(Alignment.Center)
          )
      }
  }
-----------------------
Column(modifier = Modifier.fillMaxSize()) {
    Row(
        modifier = Modifier
            .fillMaxWidth()
            .height(200.dp)
            .background(color = Color.Blue)
    ) {}

    Box(
        modifier = Modifier
            .fillMaxWidth()
            .height(100.dp)
            .background(color = Color.Green)
    ) {
        
        // red circle view
        Box(
            modifier = Modifier
                .align(Alignment.TopCenter)
                .offset(y = (-40).dp)
                .size(80.dp)
                .clip(CircleShape)
                .background(color = Color.Red)
        )
    }
}

Efficient code for custom color formatting in tkinter python

copy iconCopydownload iconDownload
from tkinter import *

period_1 = ['H' ,'','','','','','','','','','','','','','','','','He']
period_2 = ['Li','Be','','','','','','','','','','','B','C','N','O','F','Ne']
period_3 = ['Na','Mg','','','','','','','','','','','Al','Si','P','S','Cl','Ar']
period_4 = """K Ca Sc Ti V Cr Mn Fe Co Ni Cu Zn Ga Ge As Se Br Kr""".split(" ")
period_5 = """Rb Sr Y Zr Nb Mo Tc Ru Rh Pd Ag Cd In Sn Sb Te I Xe""".split(" ")
period_6 = """Cs Ba * Hf Ta W Re Os Ir Pt Au Hg Tl Pb Bi Po At Rn""".split(" ")
period_7 = """Fr Ra ** Rf D Sg Bh Hs Mt Ds Rg Cn Nh Fl Mc Lv Ts Og""".split(" ")

period_6a = """La Ce Pr Nd Pm Sm Eu Gd Tb Dy Ho Er Tm Yb Lu""".split(" ")
period_7a = """Ac Th Pa U Np Pu Am Cm Bk Cf Es Fm Md No Lr""".split(" ")

# Making a list of main elements and secondary elements
main = period_1 + period_2 + period_3 + period_4 + period_5 + period_6 + period_7
sec  = period_6a + period_7a

# Colors for each group
non_m_col   = '#feab90'
alk_m_col   = '#ffe0b2'
alk_ea_col  = '#fecc81'
trans_m_col = '#d2c4e8'
halogen_col = '#a4d7a7'
metals_col  = '#feab90'
noble_g_col = '#fefffe'
act_col     = '#b2e5fd'
rare_m_col  = '#e7ee9a' 

root = Tk()

# Frame for the entire table
period_tab = Frame(root)
period_tab.pack()

# Frame for the main elements only
main_elem = Frame(period_tab)
main_elem.pack()

# Frame for the secondary elements only
sec_elem = Frame(period_tab)
sec_elem.pack(pady=10)

# Creating a 7x18 table of buttons and appending it to a 2D python list for main elements
buttons = []
for i in range(7):
    temp = []
    for j in range(18):
        but = Button(main_elem,text=main[18*i+j],width=10,bg='#f0f0f0')
        but.grid(row=i,column=j)
        temp.append(but)
    buttons.append(temp)

# Creating a 2x15 table of buttons for secondary elements
for i in range(2):
    for j in range(15):
        text = sec[15*i+j]
        if i == 0: # If row 1 then different color
            Button(sec_elem,text=text,width=10,bg=rare_m_col).grid(row=i,column=j)
        else:
            Button(sec_elem,text=text,width=10,bg=act_col).grid(row=i,column=j)
            
# Manually pick out main elements from the table
non_metals     = buttons[0][0],buttons[1][12:16],buttons[2][13:16],buttons[3][14:16],buttons[4][15]
alk_metals     = [row[0] for row in buttons[1:]]
alk_ea_metals  = [row[1] for row in buttons[1:]]
halogens       = [row[16] for row in buttons[1:]]
noble_gases    = [row[-1] for row in buttons[:]]
transition_met = [buttons[x][3:12] for x in range(3,7)]
metals         = buttons[6][12:16],buttons[5][12:16],buttons[4][12:15],buttons[3][12:14],buttons[2][12]
rare_metals    = [row[2] for row in buttons[3:6]]
actinoid       = buttons[-1][2]
plain_but      = buttons[0][1:-1],buttons[1][2:12],buttons[2][2:12]

# Change colors for those main element buttons
actinoid['bg'] = act_col
for i in alk_metals:    i['bg'] = alk_m_col
for i in alk_ea_metals: i['bg'] = alk_ea_col
for i in halogens:      i['bg'] = halogen_col
for i in noble_gases:   i['bg'] = noble_g_col
for i in rare_metals:   i['bg'] = rare_m_col

for i in transition_met:
    for j in i:
        j['bg'] = trans_m_col

for i in non_metals:
    if isinstance(i,list):
        for j in i:
            j.config(bg=non_m_col)
    else:
        i.config(bg=non_m_col)

for i in metals:
    if isinstance(i,list):
        for j in i:
            j.config(bg=metals_col)
    else:
        i.config(bg=metals_col)
 
for i in plain_but:
    for j in i:
        j['relief'] = 'flat'

Button(root,text='EXIT',command=root.destroy).pack(pady=10)

root.mainloop()
-----------------------
symbols = ['H','He','Li','Be','B','C','N','O','F','Ne',
           'Na','Mg','Al','Si','P','S','Cl','Ar','K', 'Ca',
           'Sc', 'Ti', 'V','Cr', 'Mn', 'Fe', 'Co', 'Ni',
           'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr',
           'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru',
           'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te',
           'I', 'Xe','Cs', 'Ba','La', 'Ce', 'Pr', 'Nd', 'Pm',
           'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm',
           'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir',
           'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn',
           'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am',
           'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr',
           'Rf', 'Db', 'Sg', 'Bh','Hs', 'Mt', 'Ds', 'Rg', 'Cn',
           'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
keywords =['name','index','elementkategorie','gruppe','periode','block',
           'atommasse','aggregatzustand','dichte','elektronegativität']

values = [['Wasserstoff',1,'Nichtmetalle',1,1,'s',1.01,'gasförmig',0.08,2.2],#H
          ['Helium',2,'Edelgase',18,1,'s',4.00,'gasförmig',0.18,'n.A'],#He
          ['Lithium',3,'Alkalimetalle',1,2,'s',6.94,'fest',0.53,0.98],#Li
          ['Beryllium',4,'Erdalkalimetalle',2,2,'s',9.01,'fest',1.84,1.57],#Be
          ['Bor',5,'Halbmetalle',13,2,'p',10.81,'fest',2.46,2.04],#B
          ['Kohlenstoff',6,'Nichtmetalle',14,2,'p',12.01,'fest',2.26,2.55],#C
          ['Stickstoff',7,'Nichtmetalle',15,2,'p',14.00,'gasförmig',1.17,3.04],#N
          ['Sauerstoff',8,'Nichtmetalle',16,2,'p',15.99,'gasförmig',1.43,3.44],#O
          ['Fluor',9,'Halogene',17,2,'p',18.99,'gasförmig',1.70,3.98],#F
          ['Neon',10,'Edelgase',18,2,'p',20.17,'gasförmig',0.90,'n.A'],#Ne
      
          ['Natrium',11,'Alkalimetalle',1,3,'s',22.99,'fest',0.97,0.93],#Na
          ['Magnesium',12,'Erdalkalimetalle',2,3,'s',24.31,'fest',1.74,1.31],#Mg
          ['Aluminium',13,'Metalle',13,3,'p',26.98,'fest',2.69,1.61],#Al
          ['Silicium',14,'Halbmetalle',14,3,'p',28.08,'fest',2.34,1.90],#Si
          ['Phosphor',15,'Nichtmetalle',15,3,'p',30.97,'fest',2.4,2.19],#P
          ['Schwefel',16,'Nichtmetalle',16,3,'p',32.06,'fest',2.07,2.58],#S
          ['Chlor',17,'Halogene',17,3,'p',35.45,'gasförmig',3.22,3.16],#Cl
          ['Argon',18,'Edelgase',18,3,'p',39.95,'gasförmig',1.78,'n.A'],#Ar
          ['Kalium',19,'Alkalimetalle',1,4,'s',39.09,'fest',0.86,0.82],#K
          ['Calicium',20,'Erdalkalimetalle',2,4,'s',40.08,'fest',1.55,1.00],#Ca
         
          ['Scandium',21,'Übergangsmetalle',3,4,'d',44.96,'fest',2.99,1.36],#Sc
          ['Titan',22,'Übergangsmetalle',4,4,'d',47.87,'fest',4.5,1.54],#Ti
          ['Vandium',23,'Übergangsmetalle',5,4,'d',50.94,'fest',6.11,1.63],#V
          ['Chrom',24,'Übergangsmetalle',6,4,'d',51.99,'fest',7.14,1.66],#Cr
          ['Mangan',25,'Übergangsmetalle',7,4,'d',54.94,'fest',7.43,1.55],#Mn
          ['Eisen',26,'Übergangsmetalle',8,4,'d',55.85,'fest',7.87,1.83],#Fe
          ['Cobalt',27,'Übergangsmetalle',9,4,'d',58.93,'fest',8.90,1.88],#Co
          ['Nickel',28,'Übergangsmetalle',10,4,'d',58.69,'fest',8.90,1.91],#Ni
       
          ['Kupfer',29,'Übergangsmetalle',11,4,'d',63.54,'fest',8.92,1.90],#Cu
          ['Zink',30,'Übergangsmetalle',12,4,'d',65.38,'fest',7.14,1.65],#Zn
          ['Gallium',31,'Metalle',13,4,'p',69.72,'fest',5.90,1.81],#Ga
          ['Germanium',32,'Halbmetalle',14,4,'p',72.63,'fest',5.32,2.01],#Ge
          ['Arsen',33,'Halbmetalle',15,4,'p',74.92,'fest',5.73,2.18],#As
          ['Selen',34,'Halbmetalle',16,4,'p',78.97,'fest',4.82,2.55],#Se
          ['Brom',35,'Halogene',17,4,'p',79.90,'flüssig',3.12,2.96],#Br
          ['Krypton',36,'Edelgase',18,4,'p',83.80,'gasförmig',3.75,3.00],#Kr
         
          ['Rubidium',37,'Alkalimetalle',1,5,'s',85.47,'fest',1.53,0.82],#Rb
          ['Strontium',38,'Erdalkalimetalle',2,5,'s',87.62,'fest',2.63,0.95],#Sr
          ['Yttrium',39,'Übergangsmetalle',3,5,'d',88.91,'fest',4.47,1.22],#Y
          ['Zirconium',40,'Übergangsmetalle',4,5,'d',91.22,'fest',6.50,1.33],#Zr
          ['Niob',41,'Übergangsmetalle',5,5,'d',92.90,'fest',8.57,1.6],#Nb
          ['Molybdän',42,'Übergangsmetalle',6,5,'d',95.95,'fest',10.28,2.16],#Mo
          ['Technetium',43,'Übergangsmetalle',7,5,'d',98.90,'fest',11.5,1.9],#Tc
          ['Ruthenium',44,'Übergangsmetalle',8,5,'d',101.07,'fest',12.37,2.2],#Ru
         
          ['Rhodium',45,'Übergangsmetalle',9,5,'d',102.90,'fest',12.38,2.28],#Rh
          ['Palladium',46,'Übergangsmetalle',10,5,'d',106.42,'fest',11.99,2.20],#Pd
          ['Silber',47,'Übergangsmetalle',11,5,'d',107.87,'fest',10.49,1.93],#Ag
          ['cadmium',48,'Übergangsmetalle',12,5,'d',112.41,'fest',8.65,1.69],#Cd
          ['Indium',49,'Metalle',13,5,'p',114.82,'fest',7.31,1.78],#In
          ['Zinn',50,'Metalle',14,5,'p',118.71,'fest',5.77,1.96],#Sn
          ['Antimon',51,'Halbmetalle',15,5,'p',121.76,'fest',6.70,2.05],#Sb
          ['Tellur',52,'Halbmetalle',16,5,'p',127.60,'fest',6.24,2.10],#Te
      
          ['Iod',53,'Halogene',17,5,'p',126.90,'fest',4.94,2.66],#I
          ['Xenon',54,'Edelgase',18,5,'p',131.29,'gasförmig',5.90,2.6],#Xe
          ['Caesium',55,'Alkalimetalle',1,6,'s',132.91,'fest',1.90,0.79],#Cs
          ['Barium',56,'Erdalkalimetalle',2,6,'s',137.33,'fest',3.62,0.89],#Ba
          ['Lanthan',57,'Übergangsmetalle',3,6,'d',138.90,'fest',6.17,1.1],#La
          ['Cer',58,'Lanthanoide','La',6,'f',140.12,'fest',6.77,1.12],#Ce
          ['Praseodym',59,'Lanthanoide','La',6,'f',140.91,'fest',6.48,1.13],#Pr
          ['Neodym',60,'Lanthanoide','La',6,'f',144.24,'fest',7.00,1.14],#Nd
          ['Promethium',61,'Lanthanoide','La',6,'f',146.91,'fest',7.2,'n.A.'],#Pm
       
          ['Samarium',62,'Lanthanoide','La',6,'f',150.36,'fest',7.54,1.17],#Sm
          ['Europium',63,'Lanthanoide','La',6,'f',151.96,'fest',5.25,'n.A'],#Eu
          ['Gadolinium',64,'Lanthanoide','La',6,'f',157.25,'fest',7.89,1.20],#Gd
          ['Terbium',65,'Lanthanoide','La',6,'f',158.93,'fest',8.25,'n.A'],#Tb
          ['Dysprosium',66,'Lanthanoide','La',6,'f',162.50,'fest',8.56,1.22],#Dy
          ['Holmium',67,'Lanthanoide','La',6,'f',164.93,'fest',8.78,1.23],#Ho
          ['Erbium',68,'Lanthanoide','La',6,'f',167.26,'fest',9.05,1.24],#Er
          ['Thulium',69,'Lanthanoide','La',6,'f',168.93,'fest',9.32,1.25],#Tm
         
          ['Ytterbium',70,'Lanthanoide','La',6,'f',173.05,'fest',6.97,'n.A'],#Yb
          ['Lutetium',71,'Lanthanoide','La',6,'f',174.97,'fest',9.84,1.27],#Lu
          ['Hafnium',72,'Übergangsmetalle',4,6,'d',178.49,'fest',13.28,1.3],#Hf
          ['Tantal',73,'Übergangsmetalle',5,6,'d',180.95,'fest',16.65,1.5],#Ta
          ['Wolfram',74,'Übergangsmetalle',6,6,'d',183.84,'fest',19.25,2.36],#W
          ['Rhenium',75,'Übergangsmetalle',7,6,'d',186.21,'fest',21.00,1.9],#Re
          ['Osmium',76,'Übergangsmetalle',8,6,'d',190.23,'fest',22.59,2.2],#Os
          ['Irdium',77,'Übergangsmetalle',9,6,'d',192.22,'fest',22.56,2.2],#Ir

          ['Platin',78,'Übergangsmetalle',10,6,'d',195.08,'fest',21.45,2.2],#Pt
          ['Gold',79,'Übergangsmetalle',11,6,'d',196.97,'fest',19.32,2.54],#Au
          ['Quecksilber',80,'Übergangsmetalle',12,6,'d',200.59,'flüssig',13.55,2.00],#Hg
          ['Thalium',81,'Metalle',13,6,'p',204.38,'fest',11.85,1.62],#Tl
          ['Blei',82,'Metalle',14,6,'p',207.20,'fest',11.34,2.33],#Pb
          ['Bismut',83,'Metalle',15,6,'p',208.98,'fest',9.78,2.02],#Bi
          ['Polonium',84,'Metalle',16,6,'p',209.98,'fest',9.20,2.0],#Po
          ['Astat',85,'Halogene',17,6,'p',209.99,'fest','n.A',2.2],#At
          ['Radon',86,'Edelgase',18,6,'p',222.00,'gasförmig',9.73,'n.A'],#Rn

          ['Francium',87,'Alkalimetalle',1,7,'s',223.02,'fest','n.A',0.7],#Fr
          ['Radium',88,'Erdalkalimetalle',2,7,'s',226.03,'fest',5.5,0.9],#Ra
          ['Actinium',89,'Übergangsmetalle',3,7,'d',227.03,'fest',10.07,1.1],#Ac
          ['Thorium',90,'Actinoide','Ac',7,'f',232.04,'fest',11.72,1.3],#Th
          ['Protactinium',91,'Actinoide','Ac',7,'f',231.04,'fest',15.37,1.5],#Pa
          ['Uran',92,'Actinoide','Ac',7,'f',238.03,'fest',19.16,1.38],#U
          ['Neptunium',93,'Actinoide','Ac',7,'f',237.05,'fest',20.45,1.36],#Np
          ['Plutonium',94,'Actinoide','Ac',7,'f',244.06,'fest',19.82,1.28],#Pu
          ['Americium',95,'Actinoide','Ac',7,'f',243.06,'fest',13.67,1.3],#Am
          
          ['Curium',96,'Actinoide','Ac',7,'f',247.07,'fest',13.51,1.3],#Cm
          ['Berkelium',97,'Actinoide','Ac',7,'f',247,'fest',14.78,1.3],#Bk
          ['Californium',98,'Actinoide','Ac',7,'f',251,'fest',15.1,1.3],#Cf
          ['Einsteinium',99,'Actinoide','Ac',7,'f',252,'fest',8.84,'n.A'],#Es
          ['Fermium',100,'Actinoide','Ac',7,'f',257.10,'fest','n.A','n.A'],#Fm
          ['Medelevium',101,'Actinoide','Ac',7,'f',258,'fest','n.A','n.A'],#Md
          ['Nobelium',102,'Actinoide','Ac',7,'f',259,'fest','n.A.','n.A'],#No
          ['Lawrencium',103,'Actinoide','Ac',7,'f',266,'fest','n.A','n.A'],#Lr
          
          ['Rutherdordium',104,'Übergangsmetalle',4,7,'d',261.11,'fest',17.00,'n.A'],#Rf
          ['Dubnium',105,'Übergangsmetalle',5,7,'d',262.11,'n.A','n.A','n.A'],#Db
          ['Seaborgium',106,'Übergangsmetalle',6,7,'d',263.12,'n.A','n.A','n.A'],#Sg
          ['Bohrium',107,'Übergangsmetalle',7,7,'d',262.12,'n.A','n.A','n.A'],#Bh
          ['Hassium',108,'Übergangsmetalle',8,7,'d',265,'n.A','n.A','n.A'],#Hs
          ['Meitnerium',109,'Unbekannt',9,7,'d',268,'n.A','n.A','n.A'],#Mt
          ['Darmstadtium',110,'Unbekannt',10,7,'d',281,'n.A','n.A','n.A'],#Ds
          ['Roentgenium',111,'Unbekannt',11,7,'d',280,'n.A','n.A','n.A'],#Rg
          ['Copernicium',112,'Unbekannt',12,7,'d',277,'n.A','n.A','n.A'],#Cn

          ['Nihonium',113,'Unbekannt',13,7,'p',287,'n.A','n.A','n.A'],#Nh
          ['Flerovium',114,'Unbekannt',14,7,'p',289,'n.A','n.A','n.A'],#Fl
          ['Moscovium',115,'Unbekannt',15,7,'p',288,'n.A','n.A','n.A'],#Mc
          ['Livermorium',116,'Unbekannt',16,7,'p',293,'n.A','n.A','n.A'],#Lv
          ['Tenness',117,'Unbekannt',17,7,'p',292,'n.A','n.A','n.A'],#Ts
          ['Oganesson',118,'Unbekannt',18,7,'p',294,'fest',6.6,'n.A']#Og
          ]
kategorie_farben = {'Alkalimetalle' : '#fe6f61',
                    'Erdalkalimetalle':'#6791a7',
                    'Übergangsmetalle':'#83b8d0',
                    'Metalle':'#cae2ed',
                    'Halbmetalle':'#a7d6bc',
                    'Nichtmetalle':'#ffde66',
                    'Halogene':'#e9aa63',
                    'Edelgase':'#e29136',
                    'Unbekannt':'#cec0bf',
                    'Lanthanoide':'#696071',
                    'Actinoide':'#5b4c68'}
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            var = 2
            if c is 'La':
                c =Element.la_offset+var;Element.la_offset +=1
                r += self.offset
            if c is 'Ac':
                c =Element.ac_offset+var;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
import tkinter as tk
root = tk.Tk()
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,**kwargs)
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.command= kwargs.pop('command', lambda:print('No command'))
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            if c == 'La':
                c =Element.la_offset+Element.offset;Element.la_offset +=1
                r += self.offset
            if c == 'Ac':
                c =Element.ac_offset+Element.offset;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
        self.bind('<Enter>', self.in_active)
        self.bind('<Leave>', self.in_active)
        self.bind('<ButtonPress-1>', self.indicate)
        self.bind('<ButtonRelease-1>', self.execute)
        [child.bind('<ButtonPress-1>', self.indicate) for child in self.winfo_children()]
        [child.bind('<ButtonRelease-1>', self.execute) for child in self.winfo_children()]
    def in_active(self,event):
        if str(event.type) == 'Enter': self.flag = True
        if str(event.type) == 'Leave':
            self.flag = False;self.configure(relief='raised')
    def indicate(self,event):
        self.configure(relief='sunken')
    def execute(self,event):
        if self.flag: self.command();self.configure(relief='raised')
        else: self.configure(relief='raised')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
def test():
    print('testing..')
        
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,command=test,**kwargs)
-----------------------
symbols = ['H','He','Li','Be','B','C','N','O','F','Ne',
           'Na','Mg','Al','Si','P','S','Cl','Ar','K', 'Ca',
           'Sc', 'Ti', 'V','Cr', 'Mn', 'Fe', 'Co', 'Ni',
           'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr',
           'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru',
           'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te',
           'I', 'Xe','Cs', 'Ba','La', 'Ce', 'Pr', 'Nd', 'Pm',
           'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm',
           'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir',
           'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn',
           'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am',
           'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr',
           'Rf', 'Db', 'Sg', 'Bh','Hs', 'Mt', 'Ds', 'Rg', 'Cn',
           'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
keywords =['name','index','elementkategorie','gruppe','periode','block',
           'atommasse','aggregatzustand','dichte','elektronegativität']

values = [['Wasserstoff',1,'Nichtmetalle',1,1,'s',1.01,'gasförmig',0.08,2.2],#H
          ['Helium',2,'Edelgase',18,1,'s',4.00,'gasförmig',0.18,'n.A'],#He
          ['Lithium',3,'Alkalimetalle',1,2,'s',6.94,'fest',0.53,0.98],#Li
          ['Beryllium',4,'Erdalkalimetalle',2,2,'s',9.01,'fest',1.84,1.57],#Be
          ['Bor',5,'Halbmetalle',13,2,'p',10.81,'fest',2.46,2.04],#B
          ['Kohlenstoff',6,'Nichtmetalle',14,2,'p',12.01,'fest',2.26,2.55],#C
          ['Stickstoff',7,'Nichtmetalle',15,2,'p',14.00,'gasförmig',1.17,3.04],#N
          ['Sauerstoff',8,'Nichtmetalle',16,2,'p',15.99,'gasförmig',1.43,3.44],#O
          ['Fluor',9,'Halogene',17,2,'p',18.99,'gasförmig',1.70,3.98],#F
          ['Neon',10,'Edelgase',18,2,'p',20.17,'gasförmig',0.90,'n.A'],#Ne
      
          ['Natrium',11,'Alkalimetalle',1,3,'s',22.99,'fest',0.97,0.93],#Na
          ['Magnesium',12,'Erdalkalimetalle',2,3,'s',24.31,'fest',1.74,1.31],#Mg
          ['Aluminium',13,'Metalle',13,3,'p',26.98,'fest',2.69,1.61],#Al
          ['Silicium',14,'Halbmetalle',14,3,'p',28.08,'fest',2.34,1.90],#Si
          ['Phosphor',15,'Nichtmetalle',15,3,'p',30.97,'fest',2.4,2.19],#P
          ['Schwefel',16,'Nichtmetalle',16,3,'p',32.06,'fest',2.07,2.58],#S
          ['Chlor',17,'Halogene',17,3,'p',35.45,'gasförmig',3.22,3.16],#Cl
          ['Argon',18,'Edelgase',18,3,'p',39.95,'gasförmig',1.78,'n.A'],#Ar
          ['Kalium',19,'Alkalimetalle',1,4,'s',39.09,'fest',0.86,0.82],#K
          ['Calicium',20,'Erdalkalimetalle',2,4,'s',40.08,'fest',1.55,1.00],#Ca
         
          ['Scandium',21,'Übergangsmetalle',3,4,'d',44.96,'fest',2.99,1.36],#Sc
          ['Titan',22,'Übergangsmetalle',4,4,'d',47.87,'fest',4.5,1.54],#Ti
          ['Vandium',23,'Übergangsmetalle',5,4,'d',50.94,'fest',6.11,1.63],#V
          ['Chrom',24,'Übergangsmetalle',6,4,'d',51.99,'fest',7.14,1.66],#Cr
          ['Mangan',25,'Übergangsmetalle',7,4,'d',54.94,'fest',7.43,1.55],#Mn
          ['Eisen',26,'Übergangsmetalle',8,4,'d',55.85,'fest',7.87,1.83],#Fe
          ['Cobalt',27,'Übergangsmetalle',9,4,'d',58.93,'fest',8.90,1.88],#Co
          ['Nickel',28,'Übergangsmetalle',10,4,'d',58.69,'fest',8.90,1.91],#Ni
       
          ['Kupfer',29,'Übergangsmetalle',11,4,'d',63.54,'fest',8.92,1.90],#Cu
          ['Zink',30,'Übergangsmetalle',12,4,'d',65.38,'fest',7.14,1.65],#Zn
          ['Gallium',31,'Metalle',13,4,'p',69.72,'fest',5.90,1.81],#Ga
          ['Germanium',32,'Halbmetalle',14,4,'p',72.63,'fest',5.32,2.01],#Ge
          ['Arsen',33,'Halbmetalle',15,4,'p',74.92,'fest',5.73,2.18],#As
          ['Selen',34,'Halbmetalle',16,4,'p',78.97,'fest',4.82,2.55],#Se
          ['Brom',35,'Halogene',17,4,'p',79.90,'flüssig',3.12,2.96],#Br
          ['Krypton',36,'Edelgase',18,4,'p',83.80,'gasförmig',3.75,3.00],#Kr
         
          ['Rubidium',37,'Alkalimetalle',1,5,'s',85.47,'fest',1.53,0.82],#Rb
          ['Strontium',38,'Erdalkalimetalle',2,5,'s',87.62,'fest',2.63,0.95],#Sr
          ['Yttrium',39,'Übergangsmetalle',3,5,'d',88.91,'fest',4.47,1.22],#Y
          ['Zirconium',40,'Übergangsmetalle',4,5,'d',91.22,'fest',6.50,1.33],#Zr
          ['Niob',41,'Übergangsmetalle',5,5,'d',92.90,'fest',8.57,1.6],#Nb
          ['Molybdän',42,'Übergangsmetalle',6,5,'d',95.95,'fest',10.28,2.16],#Mo
          ['Technetium',43,'Übergangsmetalle',7,5,'d',98.90,'fest',11.5,1.9],#Tc
          ['Ruthenium',44,'Übergangsmetalle',8,5,'d',101.07,'fest',12.37,2.2],#Ru
         
          ['Rhodium',45,'Übergangsmetalle',9,5,'d',102.90,'fest',12.38,2.28],#Rh
          ['Palladium',46,'Übergangsmetalle',10,5,'d',106.42,'fest',11.99,2.20],#Pd
          ['Silber',47,'Übergangsmetalle',11,5,'d',107.87,'fest',10.49,1.93],#Ag
          ['cadmium',48,'Übergangsmetalle',12,5,'d',112.41,'fest',8.65,1.69],#Cd
          ['Indium',49,'Metalle',13,5,'p',114.82,'fest',7.31,1.78],#In
          ['Zinn',50,'Metalle',14,5,'p',118.71,'fest',5.77,1.96],#Sn
          ['Antimon',51,'Halbmetalle',15,5,'p',121.76,'fest',6.70,2.05],#Sb
          ['Tellur',52,'Halbmetalle',16,5,'p',127.60,'fest',6.24,2.10],#Te
      
          ['Iod',53,'Halogene',17,5,'p',126.90,'fest',4.94,2.66],#I
          ['Xenon',54,'Edelgase',18,5,'p',131.29,'gasförmig',5.90,2.6],#Xe
          ['Caesium',55,'Alkalimetalle',1,6,'s',132.91,'fest',1.90,0.79],#Cs
          ['Barium',56,'Erdalkalimetalle',2,6,'s',137.33,'fest',3.62,0.89],#Ba
          ['Lanthan',57,'Übergangsmetalle',3,6,'d',138.90,'fest',6.17,1.1],#La
          ['Cer',58,'Lanthanoide','La',6,'f',140.12,'fest',6.77,1.12],#Ce
          ['Praseodym',59,'Lanthanoide','La',6,'f',140.91,'fest',6.48,1.13],#Pr
          ['Neodym',60,'Lanthanoide','La',6,'f',144.24,'fest',7.00,1.14],#Nd
          ['Promethium',61,'Lanthanoide','La',6,'f',146.91,'fest',7.2,'n.A.'],#Pm
       
          ['Samarium',62,'Lanthanoide','La',6,'f',150.36,'fest',7.54,1.17],#Sm
          ['Europium',63,'Lanthanoide','La',6,'f',151.96,'fest',5.25,'n.A'],#Eu
          ['Gadolinium',64,'Lanthanoide','La',6,'f',157.25,'fest',7.89,1.20],#Gd
          ['Terbium',65,'Lanthanoide','La',6,'f',158.93,'fest',8.25,'n.A'],#Tb
          ['Dysprosium',66,'Lanthanoide','La',6,'f',162.50,'fest',8.56,1.22],#Dy
          ['Holmium',67,'Lanthanoide','La',6,'f',164.93,'fest',8.78,1.23],#Ho
          ['Erbium',68,'Lanthanoide','La',6,'f',167.26,'fest',9.05,1.24],#Er
          ['Thulium',69,'Lanthanoide','La',6,'f',168.93,'fest',9.32,1.25],#Tm
         
          ['Ytterbium',70,'Lanthanoide','La',6,'f',173.05,'fest',6.97,'n.A'],#Yb
          ['Lutetium',71,'Lanthanoide','La',6,'f',174.97,'fest',9.84,1.27],#Lu
          ['Hafnium',72,'Übergangsmetalle',4,6,'d',178.49,'fest',13.28,1.3],#Hf
          ['Tantal',73,'Übergangsmetalle',5,6,'d',180.95,'fest',16.65,1.5],#Ta
          ['Wolfram',74,'Übergangsmetalle',6,6,'d',183.84,'fest',19.25,2.36],#W
          ['Rhenium',75,'Übergangsmetalle',7,6,'d',186.21,'fest',21.00,1.9],#Re
          ['Osmium',76,'Übergangsmetalle',8,6,'d',190.23,'fest',22.59,2.2],#Os
          ['Irdium',77,'Übergangsmetalle',9,6,'d',192.22,'fest',22.56,2.2],#Ir

          ['Platin',78,'Übergangsmetalle',10,6,'d',195.08,'fest',21.45,2.2],#Pt
          ['Gold',79,'Übergangsmetalle',11,6,'d',196.97,'fest',19.32,2.54],#Au
          ['Quecksilber',80,'Übergangsmetalle',12,6,'d',200.59,'flüssig',13.55,2.00],#Hg
          ['Thalium',81,'Metalle',13,6,'p',204.38,'fest',11.85,1.62],#Tl
          ['Blei',82,'Metalle',14,6,'p',207.20,'fest',11.34,2.33],#Pb
          ['Bismut',83,'Metalle',15,6,'p',208.98,'fest',9.78,2.02],#Bi
          ['Polonium',84,'Metalle',16,6,'p',209.98,'fest',9.20,2.0],#Po
          ['Astat',85,'Halogene',17,6,'p',209.99,'fest','n.A',2.2],#At
          ['Radon',86,'Edelgase',18,6,'p',222.00,'gasförmig',9.73,'n.A'],#Rn

          ['Francium',87,'Alkalimetalle',1,7,'s',223.02,'fest','n.A',0.7],#Fr
          ['Radium',88,'Erdalkalimetalle',2,7,'s',226.03,'fest',5.5,0.9],#Ra
          ['Actinium',89,'Übergangsmetalle',3,7,'d',227.03,'fest',10.07,1.1],#Ac
          ['Thorium',90,'Actinoide','Ac',7,'f',232.04,'fest',11.72,1.3],#Th
          ['Protactinium',91,'Actinoide','Ac',7,'f',231.04,'fest',15.37,1.5],#Pa
          ['Uran',92,'Actinoide','Ac',7,'f',238.03,'fest',19.16,1.38],#U
          ['Neptunium',93,'Actinoide','Ac',7,'f',237.05,'fest',20.45,1.36],#Np
          ['Plutonium',94,'Actinoide','Ac',7,'f',244.06,'fest',19.82,1.28],#Pu
          ['Americium',95,'Actinoide','Ac',7,'f',243.06,'fest',13.67,1.3],#Am
          
          ['Curium',96,'Actinoide','Ac',7,'f',247.07,'fest',13.51,1.3],#Cm
          ['Berkelium',97,'Actinoide','Ac',7,'f',247,'fest',14.78,1.3],#Bk
          ['Californium',98,'Actinoide','Ac',7,'f',251,'fest',15.1,1.3],#Cf
          ['Einsteinium',99,'Actinoide','Ac',7,'f',252,'fest',8.84,'n.A'],#Es
          ['Fermium',100,'Actinoide','Ac',7,'f',257.10,'fest','n.A','n.A'],#Fm
          ['Medelevium',101,'Actinoide','Ac',7,'f',258,'fest','n.A','n.A'],#Md
          ['Nobelium',102,'Actinoide','Ac',7,'f',259,'fest','n.A.','n.A'],#No
          ['Lawrencium',103,'Actinoide','Ac',7,'f',266,'fest','n.A','n.A'],#Lr
          
          ['Rutherdordium',104,'Übergangsmetalle',4,7,'d',261.11,'fest',17.00,'n.A'],#Rf
          ['Dubnium',105,'Übergangsmetalle',5,7,'d',262.11,'n.A','n.A','n.A'],#Db
          ['Seaborgium',106,'Übergangsmetalle',6,7,'d',263.12,'n.A','n.A','n.A'],#Sg
          ['Bohrium',107,'Übergangsmetalle',7,7,'d',262.12,'n.A','n.A','n.A'],#Bh
          ['Hassium',108,'Übergangsmetalle',8,7,'d',265,'n.A','n.A','n.A'],#Hs
          ['Meitnerium',109,'Unbekannt',9,7,'d',268,'n.A','n.A','n.A'],#Mt
          ['Darmstadtium',110,'Unbekannt',10,7,'d',281,'n.A','n.A','n.A'],#Ds
          ['Roentgenium',111,'Unbekannt',11,7,'d',280,'n.A','n.A','n.A'],#Rg
          ['Copernicium',112,'Unbekannt',12,7,'d',277,'n.A','n.A','n.A'],#Cn

          ['Nihonium',113,'Unbekannt',13,7,'p',287,'n.A','n.A','n.A'],#Nh
          ['Flerovium',114,'Unbekannt',14,7,'p',289,'n.A','n.A','n.A'],#Fl
          ['Moscovium',115,'Unbekannt',15,7,'p',288,'n.A','n.A','n.A'],#Mc
          ['Livermorium',116,'Unbekannt',16,7,'p',293,'n.A','n.A','n.A'],#Lv
          ['Tenness',117,'Unbekannt',17,7,'p',292,'n.A','n.A','n.A'],#Ts
          ['Oganesson',118,'Unbekannt',18,7,'p',294,'fest',6.6,'n.A']#Og
          ]
kategorie_farben = {'Alkalimetalle' : '#fe6f61',
                    'Erdalkalimetalle':'#6791a7',
                    'Übergangsmetalle':'#83b8d0',
                    'Metalle':'#cae2ed',
                    'Halbmetalle':'#a7d6bc',
                    'Nichtmetalle':'#ffde66',
                    'Halogene':'#e9aa63',
                    'Edelgase':'#e29136',
                    'Unbekannt':'#cec0bf',
                    'Lanthanoide':'#696071',
                    'Actinoide':'#5b4c68'}
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            var = 2
            if c is 'La':
                c =Element.la_offset+var;Element.la_offset +=1
                r += self.offset
            if c is 'Ac':
                c =Element.ac_offset+var;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
import tkinter as tk
root = tk.Tk()
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,**kwargs)
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.command= kwargs.pop('command', lambda:print('No command'))
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            if c == 'La':
                c =Element.la_offset+Element.offset;Element.la_offset +=1
                r += self.offset
            if c == 'Ac':
                c =Element.ac_offset+Element.offset;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
        self.bind('<Enter>', self.in_active)
        self.bind('<Leave>', self.in_active)
        self.bind('<ButtonPress-1>', self.indicate)
        self.bind('<ButtonRelease-1>', self.execute)
        [child.bind('<ButtonPress-1>', self.indicate) for child in self.winfo_children()]
        [child.bind('<ButtonRelease-1>', self.execute) for child in self.winfo_children()]
    def in_active(self,event):
        if str(event.type) == 'Enter': self.flag = True
        if str(event.type) == 'Leave':
            self.flag = False;self.configure(relief='raised')
    def indicate(self,event):
        self.configure(relief='sunken')
    def execute(self,event):
        if self.flag: self.command();self.configure(relief='raised')
        else: self.configure(relief='raised')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
def test():
    print('testing..')
        
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,command=test,**kwargs)
-----------------------
symbols = ['H','He','Li','Be','B','C','N','O','F','Ne',
           'Na','Mg','Al','Si','P','S','Cl','Ar','K', 'Ca',
           'Sc', 'Ti', 'V','Cr', 'Mn', 'Fe', 'Co', 'Ni',
           'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr',
           'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru',
           'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te',
           'I', 'Xe','Cs', 'Ba','La', 'Ce', 'Pr', 'Nd', 'Pm',
           'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm',
           'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir',
           'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn',
           'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am',
           'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr',
           'Rf', 'Db', 'Sg', 'Bh','Hs', 'Mt', 'Ds', 'Rg', 'Cn',
           'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
keywords =['name','index','elementkategorie','gruppe','periode','block',
           'atommasse','aggregatzustand','dichte','elektronegativität']

values = [['Wasserstoff',1,'Nichtmetalle',1,1,'s',1.01,'gasförmig',0.08,2.2],#H
          ['Helium',2,'Edelgase',18,1,'s',4.00,'gasförmig',0.18,'n.A'],#He
          ['Lithium',3,'Alkalimetalle',1,2,'s',6.94,'fest',0.53,0.98],#Li
          ['Beryllium',4,'Erdalkalimetalle',2,2,'s',9.01,'fest',1.84,1.57],#Be
          ['Bor',5,'Halbmetalle',13,2,'p',10.81,'fest',2.46,2.04],#B
          ['Kohlenstoff',6,'Nichtmetalle',14,2,'p',12.01,'fest',2.26,2.55],#C
          ['Stickstoff',7,'Nichtmetalle',15,2,'p',14.00,'gasförmig',1.17,3.04],#N
          ['Sauerstoff',8,'Nichtmetalle',16,2,'p',15.99,'gasförmig',1.43,3.44],#O
          ['Fluor',9,'Halogene',17,2,'p',18.99,'gasförmig',1.70,3.98],#F
          ['Neon',10,'Edelgase',18,2,'p',20.17,'gasförmig',0.90,'n.A'],#Ne
      
          ['Natrium',11,'Alkalimetalle',1,3,'s',22.99,'fest',0.97,0.93],#Na
          ['Magnesium',12,'Erdalkalimetalle',2,3,'s',24.31,'fest',1.74,1.31],#Mg
          ['Aluminium',13,'Metalle',13,3,'p',26.98,'fest',2.69,1.61],#Al
          ['Silicium',14,'Halbmetalle',14,3,'p',28.08,'fest',2.34,1.90],#Si
          ['Phosphor',15,'Nichtmetalle',15,3,'p',30.97,'fest',2.4,2.19],#P
          ['Schwefel',16,'Nichtmetalle',16,3,'p',32.06,'fest',2.07,2.58],#S
          ['Chlor',17,'Halogene',17,3,'p',35.45,'gasförmig',3.22,3.16],#Cl
          ['Argon',18,'Edelgase',18,3,'p',39.95,'gasförmig',1.78,'n.A'],#Ar
          ['Kalium',19,'Alkalimetalle',1,4,'s',39.09,'fest',0.86,0.82],#K
          ['Calicium',20,'Erdalkalimetalle',2,4,'s',40.08,'fest',1.55,1.00],#Ca
         
          ['Scandium',21,'Übergangsmetalle',3,4,'d',44.96,'fest',2.99,1.36],#Sc
          ['Titan',22,'Übergangsmetalle',4,4,'d',47.87,'fest',4.5,1.54],#Ti
          ['Vandium',23,'Übergangsmetalle',5,4,'d',50.94,'fest',6.11,1.63],#V
          ['Chrom',24,'Übergangsmetalle',6,4,'d',51.99,'fest',7.14,1.66],#Cr
          ['Mangan',25,'Übergangsmetalle',7,4,'d',54.94,'fest',7.43,1.55],#Mn
          ['Eisen',26,'Übergangsmetalle',8,4,'d',55.85,'fest',7.87,1.83],#Fe
          ['Cobalt',27,'Übergangsmetalle',9,4,'d',58.93,'fest',8.90,1.88],#Co
          ['Nickel',28,'Übergangsmetalle',10,4,'d',58.69,'fest',8.90,1.91],#Ni
       
          ['Kupfer',29,'Übergangsmetalle',11,4,'d',63.54,'fest',8.92,1.90],#Cu
          ['Zink',30,'Übergangsmetalle',12,4,'d',65.38,'fest',7.14,1.65],#Zn
          ['Gallium',31,'Metalle',13,4,'p',69.72,'fest',5.90,1.81],#Ga
          ['Germanium',32,'Halbmetalle',14,4,'p',72.63,'fest',5.32,2.01],#Ge
          ['Arsen',33,'Halbmetalle',15,4,'p',74.92,'fest',5.73,2.18],#As
          ['Selen',34,'Halbmetalle',16,4,'p',78.97,'fest',4.82,2.55],#Se
          ['Brom',35,'Halogene',17,4,'p',79.90,'flüssig',3.12,2.96],#Br
          ['Krypton',36,'Edelgase',18,4,'p',83.80,'gasförmig',3.75,3.00],#Kr
         
          ['Rubidium',37,'Alkalimetalle',1,5,'s',85.47,'fest',1.53,0.82],#Rb
          ['Strontium',38,'Erdalkalimetalle',2,5,'s',87.62,'fest',2.63,0.95],#Sr
          ['Yttrium',39,'Übergangsmetalle',3,5,'d',88.91,'fest',4.47,1.22],#Y
          ['Zirconium',40,'Übergangsmetalle',4,5,'d',91.22,'fest',6.50,1.33],#Zr
          ['Niob',41,'Übergangsmetalle',5,5,'d',92.90,'fest',8.57,1.6],#Nb
          ['Molybdän',42,'Übergangsmetalle',6,5,'d',95.95,'fest',10.28,2.16],#Mo
          ['Technetium',43,'Übergangsmetalle',7,5,'d',98.90,'fest',11.5,1.9],#Tc
          ['Ruthenium',44,'Übergangsmetalle',8,5,'d',101.07,'fest',12.37,2.2],#Ru
         
          ['Rhodium',45,'Übergangsmetalle',9,5,'d',102.90,'fest',12.38,2.28],#Rh
          ['Palladium',46,'Übergangsmetalle',10,5,'d',106.42,'fest',11.99,2.20],#Pd
          ['Silber',47,'Übergangsmetalle',11,5,'d',107.87,'fest',10.49,1.93],#Ag
          ['cadmium',48,'Übergangsmetalle',12,5,'d',112.41,'fest',8.65,1.69],#Cd
          ['Indium',49,'Metalle',13,5,'p',114.82,'fest',7.31,1.78],#In
          ['Zinn',50,'Metalle',14,5,'p',118.71,'fest',5.77,1.96],#Sn
          ['Antimon',51,'Halbmetalle',15,5,'p',121.76,'fest',6.70,2.05],#Sb
          ['Tellur',52,'Halbmetalle',16,5,'p',127.60,'fest',6.24,2.10],#Te
      
          ['Iod',53,'Halogene',17,5,'p',126.90,'fest',4.94,2.66],#I
          ['Xenon',54,'Edelgase',18,5,'p',131.29,'gasförmig',5.90,2.6],#Xe
          ['Caesium',55,'Alkalimetalle',1,6,'s',132.91,'fest',1.90,0.79],#Cs
          ['Barium',56,'Erdalkalimetalle',2,6,'s',137.33,'fest',3.62,0.89],#Ba
          ['Lanthan',57,'Übergangsmetalle',3,6,'d',138.90,'fest',6.17,1.1],#La
          ['Cer',58,'Lanthanoide','La',6,'f',140.12,'fest',6.77,1.12],#Ce
          ['Praseodym',59,'Lanthanoide','La',6,'f',140.91,'fest',6.48,1.13],#Pr
          ['Neodym',60,'Lanthanoide','La',6,'f',144.24,'fest',7.00,1.14],#Nd
          ['Promethium',61,'Lanthanoide','La',6,'f',146.91,'fest',7.2,'n.A.'],#Pm
       
          ['Samarium',62,'Lanthanoide','La',6,'f',150.36,'fest',7.54,1.17],#Sm
          ['Europium',63,'Lanthanoide','La',6,'f',151.96,'fest',5.25,'n.A'],#Eu
          ['Gadolinium',64,'Lanthanoide','La',6,'f',157.25,'fest',7.89,1.20],#Gd
          ['Terbium',65,'Lanthanoide','La',6,'f',158.93,'fest',8.25,'n.A'],#Tb
          ['Dysprosium',66,'Lanthanoide','La',6,'f',162.50,'fest',8.56,1.22],#Dy
          ['Holmium',67,'Lanthanoide','La',6,'f',164.93,'fest',8.78,1.23],#Ho
          ['Erbium',68,'Lanthanoide','La',6,'f',167.26,'fest',9.05,1.24],#Er
          ['Thulium',69,'Lanthanoide','La',6,'f',168.93,'fest',9.32,1.25],#Tm
         
          ['Ytterbium',70,'Lanthanoide','La',6,'f',173.05,'fest',6.97,'n.A'],#Yb
          ['Lutetium',71,'Lanthanoide','La',6,'f',174.97,'fest',9.84,1.27],#Lu
          ['Hafnium',72,'Übergangsmetalle',4,6,'d',178.49,'fest',13.28,1.3],#Hf
          ['Tantal',73,'Übergangsmetalle',5,6,'d',180.95,'fest',16.65,1.5],#Ta
          ['Wolfram',74,'Übergangsmetalle',6,6,'d',183.84,'fest',19.25,2.36],#W
          ['Rhenium',75,'Übergangsmetalle',7,6,'d',186.21,'fest',21.00,1.9],#Re
          ['Osmium',76,'Übergangsmetalle',8,6,'d',190.23,'fest',22.59,2.2],#Os
          ['Irdium',77,'Übergangsmetalle',9,6,'d',192.22,'fest',22.56,2.2],#Ir

          ['Platin',78,'Übergangsmetalle',10,6,'d',195.08,'fest',21.45,2.2],#Pt
          ['Gold',79,'Übergangsmetalle',11,6,'d',196.97,'fest',19.32,2.54],#Au
          ['Quecksilber',80,'Übergangsmetalle',12,6,'d',200.59,'flüssig',13.55,2.00],#Hg
          ['Thalium',81,'Metalle',13,6,'p',204.38,'fest',11.85,1.62],#Tl
          ['Blei',82,'Metalle',14,6,'p',207.20,'fest',11.34,2.33],#Pb
          ['Bismut',83,'Metalle',15,6,'p',208.98,'fest',9.78,2.02],#Bi
          ['Polonium',84,'Metalle',16,6,'p',209.98,'fest',9.20,2.0],#Po
          ['Astat',85,'Halogene',17,6,'p',209.99,'fest','n.A',2.2],#At
          ['Radon',86,'Edelgase',18,6,'p',222.00,'gasförmig',9.73,'n.A'],#Rn

          ['Francium',87,'Alkalimetalle',1,7,'s',223.02,'fest','n.A',0.7],#Fr
          ['Radium',88,'Erdalkalimetalle',2,7,'s',226.03,'fest',5.5,0.9],#Ra
          ['Actinium',89,'Übergangsmetalle',3,7,'d',227.03,'fest',10.07,1.1],#Ac
          ['Thorium',90,'Actinoide','Ac',7,'f',232.04,'fest',11.72,1.3],#Th
          ['Protactinium',91,'Actinoide','Ac',7,'f',231.04,'fest',15.37,1.5],#Pa
          ['Uran',92,'Actinoide','Ac',7,'f',238.03,'fest',19.16,1.38],#U
          ['Neptunium',93,'Actinoide','Ac',7,'f',237.05,'fest',20.45,1.36],#Np
          ['Plutonium',94,'Actinoide','Ac',7,'f',244.06,'fest',19.82,1.28],#Pu
          ['Americium',95,'Actinoide','Ac',7,'f',243.06,'fest',13.67,1.3],#Am
          
          ['Curium',96,'Actinoide','Ac',7,'f',247.07,'fest',13.51,1.3],#Cm
          ['Berkelium',97,'Actinoide','Ac',7,'f',247,'fest',14.78,1.3],#Bk
          ['Californium',98,'Actinoide','Ac',7,'f',251,'fest',15.1,1.3],#Cf
          ['Einsteinium',99,'Actinoide','Ac',7,'f',252,'fest',8.84,'n.A'],#Es
          ['Fermium',100,'Actinoide','Ac',7,'f',257.10,'fest','n.A','n.A'],#Fm
          ['Medelevium',101,'Actinoide','Ac',7,'f',258,'fest','n.A','n.A'],#Md
          ['Nobelium',102,'Actinoide','Ac',7,'f',259,'fest','n.A.','n.A'],#No
          ['Lawrencium',103,'Actinoide','Ac',7,'f',266,'fest','n.A','n.A'],#Lr
          
          ['Rutherdordium',104,'Übergangsmetalle',4,7,'d',261.11,'fest',17.00,'n.A'],#Rf
          ['Dubnium',105,'Übergangsmetalle',5,7,'d',262.11,'n.A','n.A','n.A'],#Db
          ['Seaborgium',106,'Übergangsmetalle',6,7,'d',263.12,'n.A','n.A','n.A'],#Sg
          ['Bohrium',107,'Übergangsmetalle',7,7,'d',262.12,'n.A','n.A','n.A'],#Bh
          ['Hassium',108,'Übergangsmetalle',8,7,'d',265,'n.A','n.A','n.A'],#Hs
          ['Meitnerium',109,'Unbekannt',9,7,'d',268,'n.A','n.A','n.A'],#Mt
          ['Darmstadtium',110,'Unbekannt',10,7,'d',281,'n.A','n.A','n.A'],#Ds
          ['Roentgenium',111,'Unbekannt',11,7,'d',280,'n.A','n.A','n.A'],#Rg
          ['Copernicium',112,'Unbekannt',12,7,'d',277,'n.A','n.A','n.A'],#Cn

          ['Nihonium',113,'Unbekannt',13,7,'p',287,'n.A','n.A','n.A'],#Nh
          ['Flerovium',114,'Unbekannt',14,7,'p',289,'n.A','n.A','n.A'],#Fl
          ['Moscovium',115,'Unbekannt',15,7,'p',288,'n.A','n.A','n.A'],#Mc
          ['Livermorium',116,'Unbekannt',16,7,'p',293,'n.A','n.A','n.A'],#Lv
          ['Tenness',117,'Unbekannt',17,7,'p',292,'n.A','n.A','n.A'],#Ts
          ['Oganesson',118,'Unbekannt',18,7,'p',294,'fest',6.6,'n.A']#Og
          ]
kategorie_farben = {'Alkalimetalle' : '#fe6f61',
                    'Erdalkalimetalle':'#6791a7',
                    'Übergangsmetalle':'#83b8d0',
                    'Metalle':'#cae2ed',
                    'Halbmetalle':'#a7d6bc',
                    'Nichtmetalle':'#ffde66',
                    'Halogene':'#e9aa63',
                    'Edelgase':'#e29136',
                    'Unbekannt':'#cec0bf',
                    'Lanthanoide':'#696071',
                    'Actinoide':'#5b4c68'}
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            var = 2
            if c is 'La':
                c =Element.la_offset+var;Element.la_offset +=1
                r += self.offset
            if c is 'Ac':
                c =Element.ac_offset+var;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
import tkinter as tk
root = tk.Tk()
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,**kwargs)
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.command= kwargs.pop('command', lambda:print('No command'))
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            if c == 'La':
                c =Element.la_offset+Element.offset;Element.la_offset +=1
                r += self.offset
            if c == 'Ac':
                c =Element.ac_offset+Element.offset;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
        self.bind('<Enter>', self.in_active)
        self.bind('<Leave>', self.in_active)
        self.bind('<ButtonPress-1>', self.indicate)
        self.bind('<ButtonRelease-1>', self.execute)
        [child.bind('<ButtonPress-1>', self.indicate) for child in self.winfo_children()]
        [child.bind('<ButtonRelease-1>', self.execute) for child in self.winfo_children()]
    def in_active(self,event):
        if str(event.type) == 'Enter': self.flag = True
        if str(event.type) == 'Leave':
            self.flag = False;self.configure(relief='raised')
    def indicate(self,event):
        self.configure(relief='sunken')
    def execute(self,event):
        if self.flag: self.command();self.configure(relief='raised')
        else: self.configure(relief='raised')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
def test():
    print('testing..')
        
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,command=test,**kwargs)
-----------------------
symbols = ['H','He','Li','Be','B','C','N','O','F','Ne',
           'Na','Mg','Al','Si','P','S','Cl','Ar','K', 'Ca',
           'Sc', 'Ti', 'V','Cr', 'Mn', 'Fe', 'Co', 'Ni',
           'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr',
           'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru',
           'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te',
           'I', 'Xe','Cs', 'Ba','La', 'Ce', 'Pr', 'Nd', 'Pm',
           'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm',
           'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir',
           'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn',
           'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am',
           'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr',
           'Rf', 'Db', 'Sg', 'Bh','Hs', 'Mt', 'Ds', 'Rg', 'Cn',
           'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
keywords =['name','index','elementkategorie','gruppe','periode','block',
           'atommasse','aggregatzustand','dichte','elektronegativität']

values = [['Wasserstoff',1,'Nichtmetalle',1,1,'s',1.01,'gasförmig',0.08,2.2],#H
          ['Helium',2,'Edelgase',18,1,'s',4.00,'gasförmig',0.18,'n.A'],#He
          ['Lithium',3,'Alkalimetalle',1,2,'s',6.94,'fest',0.53,0.98],#Li
          ['Beryllium',4,'Erdalkalimetalle',2,2,'s',9.01,'fest',1.84,1.57],#Be
          ['Bor',5,'Halbmetalle',13,2,'p',10.81,'fest',2.46,2.04],#B
          ['Kohlenstoff',6,'Nichtmetalle',14,2,'p',12.01,'fest',2.26,2.55],#C
          ['Stickstoff',7,'Nichtmetalle',15,2,'p',14.00,'gasförmig',1.17,3.04],#N
          ['Sauerstoff',8,'Nichtmetalle',16,2,'p',15.99,'gasförmig',1.43,3.44],#O
          ['Fluor',9,'Halogene',17,2,'p',18.99,'gasförmig',1.70,3.98],#F
          ['Neon',10,'Edelgase',18,2,'p',20.17,'gasförmig',0.90,'n.A'],#Ne
      
          ['Natrium',11,'Alkalimetalle',1,3,'s',22.99,'fest',0.97,0.93],#Na
          ['Magnesium',12,'Erdalkalimetalle',2,3,'s',24.31,'fest',1.74,1.31],#Mg
          ['Aluminium',13,'Metalle',13,3,'p',26.98,'fest',2.69,1.61],#Al
          ['Silicium',14,'Halbmetalle',14,3,'p',28.08,'fest',2.34,1.90],#Si
          ['Phosphor',15,'Nichtmetalle',15,3,'p',30.97,'fest',2.4,2.19],#P
          ['Schwefel',16,'Nichtmetalle',16,3,'p',32.06,'fest',2.07,2.58],#S
          ['Chlor',17,'Halogene',17,3,'p',35.45,'gasförmig',3.22,3.16],#Cl
          ['Argon',18,'Edelgase',18,3,'p',39.95,'gasförmig',1.78,'n.A'],#Ar
          ['Kalium',19,'Alkalimetalle',1,4,'s',39.09,'fest',0.86,0.82],#K
          ['Calicium',20,'Erdalkalimetalle',2,4,'s',40.08,'fest',1.55,1.00],#Ca
         
          ['Scandium',21,'Übergangsmetalle',3,4,'d',44.96,'fest',2.99,1.36],#Sc
          ['Titan',22,'Übergangsmetalle',4,4,'d',47.87,'fest',4.5,1.54],#Ti
          ['Vandium',23,'Übergangsmetalle',5,4,'d',50.94,'fest',6.11,1.63],#V
          ['Chrom',24,'Übergangsmetalle',6,4,'d',51.99,'fest',7.14,1.66],#Cr
          ['Mangan',25,'Übergangsmetalle',7,4,'d',54.94,'fest',7.43,1.55],#Mn
          ['Eisen',26,'Übergangsmetalle',8,4,'d',55.85,'fest',7.87,1.83],#Fe
          ['Cobalt',27,'Übergangsmetalle',9,4,'d',58.93,'fest',8.90,1.88],#Co
          ['Nickel',28,'Übergangsmetalle',10,4,'d',58.69,'fest',8.90,1.91],#Ni
       
          ['Kupfer',29,'Übergangsmetalle',11,4,'d',63.54,'fest',8.92,1.90],#Cu
          ['Zink',30,'Übergangsmetalle',12,4,'d',65.38,'fest',7.14,1.65],#Zn
          ['Gallium',31,'Metalle',13,4,'p',69.72,'fest',5.90,1.81],#Ga
          ['Germanium',32,'Halbmetalle',14,4,'p',72.63,'fest',5.32,2.01],#Ge
          ['Arsen',33,'Halbmetalle',15,4,'p',74.92,'fest',5.73,2.18],#As
          ['Selen',34,'Halbmetalle',16,4,'p',78.97,'fest',4.82,2.55],#Se
          ['Brom',35,'Halogene',17,4,'p',79.90,'flüssig',3.12,2.96],#Br
          ['Krypton',36,'Edelgase',18,4,'p',83.80,'gasförmig',3.75,3.00],#Kr
         
          ['Rubidium',37,'Alkalimetalle',1,5,'s',85.47,'fest',1.53,0.82],#Rb
          ['Strontium',38,'Erdalkalimetalle',2,5,'s',87.62,'fest',2.63,0.95],#Sr
          ['Yttrium',39,'Übergangsmetalle',3,5,'d',88.91,'fest',4.47,1.22],#Y
          ['Zirconium',40,'Übergangsmetalle',4,5,'d',91.22,'fest',6.50,1.33],#Zr
          ['Niob',41,'Übergangsmetalle',5,5,'d',92.90,'fest',8.57,1.6],#Nb
          ['Molybdän',42,'Übergangsmetalle',6,5,'d',95.95,'fest',10.28,2.16],#Mo
          ['Technetium',43,'Übergangsmetalle',7,5,'d',98.90,'fest',11.5,1.9],#Tc
          ['Ruthenium',44,'Übergangsmetalle',8,5,'d',101.07,'fest',12.37,2.2],#Ru
         
          ['Rhodium',45,'Übergangsmetalle',9,5,'d',102.90,'fest',12.38,2.28],#Rh
          ['Palladium',46,'Übergangsmetalle',10,5,'d',106.42,'fest',11.99,2.20],#Pd
          ['Silber',47,'Übergangsmetalle',11,5,'d',107.87,'fest',10.49,1.93],#Ag
          ['cadmium',48,'Übergangsmetalle',12,5,'d',112.41,'fest',8.65,1.69],#Cd
          ['Indium',49,'Metalle',13,5,'p',114.82,'fest',7.31,1.78],#In
          ['Zinn',50,'Metalle',14,5,'p',118.71,'fest',5.77,1.96],#Sn
          ['Antimon',51,'Halbmetalle',15,5,'p',121.76,'fest',6.70,2.05],#Sb
          ['Tellur',52,'Halbmetalle',16,5,'p',127.60,'fest',6.24,2.10],#Te
      
          ['Iod',53,'Halogene',17,5,'p',126.90,'fest',4.94,2.66],#I
          ['Xenon',54,'Edelgase',18,5,'p',131.29,'gasförmig',5.90,2.6],#Xe
          ['Caesium',55,'Alkalimetalle',1,6,'s',132.91,'fest',1.90,0.79],#Cs
          ['Barium',56,'Erdalkalimetalle',2,6,'s',137.33,'fest',3.62,0.89],#Ba
          ['Lanthan',57,'Übergangsmetalle',3,6,'d',138.90,'fest',6.17,1.1],#La
          ['Cer',58,'Lanthanoide','La',6,'f',140.12,'fest',6.77,1.12],#Ce
          ['Praseodym',59,'Lanthanoide','La',6,'f',140.91,'fest',6.48,1.13],#Pr
          ['Neodym',60,'Lanthanoide','La',6,'f',144.24,'fest',7.00,1.14],#Nd
          ['Promethium',61,'Lanthanoide','La',6,'f',146.91,'fest',7.2,'n.A.'],#Pm
       
          ['Samarium',62,'Lanthanoide','La',6,'f',150.36,'fest',7.54,1.17],#Sm
          ['Europium',63,'Lanthanoide','La',6,'f',151.96,'fest',5.25,'n.A'],#Eu
          ['Gadolinium',64,'Lanthanoide','La',6,'f',157.25,'fest',7.89,1.20],#Gd
          ['Terbium',65,'Lanthanoide','La',6,'f',158.93,'fest',8.25,'n.A'],#Tb
          ['Dysprosium',66,'Lanthanoide','La',6,'f',162.50,'fest',8.56,1.22],#Dy
          ['Holmium',67,'Lanthanoide','La',6,'f',164.93,'fest',8.78,1.23],#Ho
          ['Erbium',68,'Lanthanoide','La',6,'f',167.26,'fest',9.05,1.24],#Er
          ['Thulium',69,'Lanthanoide','La',6,'f',168.93,'fest',9.32,1.25],#Tm
         
          ['Ytterbium',70,'Lanthanoide','La',6,'f',173.05,'fest',6.97,'n.A'],#Yb
          ['Lutetium',71,'Lanthanoide','La',6,'f',174.97,'fest',9.84,1.27],#Lu
          ['Hafnium',72,'Übergangsmetalle',4,6,'d',178.49,'fest',13.28,1.3],#Hf
          ['Tantal',73,'Übergangsmetalle',5,6,'d',180.95,'fest',16.65,1.5],#Ta
          ['Wolfram',74,'Übergangsmetalle',6,6,'d',183.84,'fest',19.25,2.36],#W
          ['Rhenium',75,'Übergangsmetalle',7,6,'d',186.21,'fest',21.00,1.9],#Re
          ['Osmium',76,'Übergangsmetalle',8,6,'d',190.23,'fest',22.59,2.2],#Os
          ['Irdium',77,'Übergangsmetalle',9,6,'d',192.22,'fest',22.56,2.2],#Ir

          ['Platin',78,'Übergangsmetalle',10,6,'d',195.08,'fest',21.45,2.2],#Pt
          ['Gold',79,'Übergangsmetalle',11,6,'d',196.97,'fest',19.32,2.54],#Au
          ['Quecksilber',80,'Übergangsmetalle',12,6,'d',200.59,'flüssig',13.55,2.00],#Hg
          ['Thalium',81,'Metalle',13,6,'p',204.38,'fest',11.85,1.62],#Tl
          ['Blei',82,'Metalle',14,6,'p',207.20,'fest',11.34,2.33],#Pb
          ['Bismut',83,'Metalle',15,6,'p',208.98,'fest',9.78,2.02],#Bi
          ['Polonium',84,'Metalle',16,6,'p',209.98,'fest',9.20,2.0],#Po
          ['Astat',85,'Halogene',17,6,'p',209.99,'fest','n.A',2.2],#At
          ['Radon',86,'Edelgase',18,6,'p',222.00,'gasförmig',9.73,'n.A'],#Rn

          ['Francium',87,'Alkalimetalle',1,7,'s',223.02,'fest','n.A',0.7],#Fr
          ['Radium',88,'Erdalkalimetalle',2,7,'s',226.03,'fest',5.5,0.9],#Ra
          ['Actinium',89,'Übergangsmetalle',3,7,'d',227.03,'fest',10.07,1.1],#Ac
          ['Thorium',90,'Actinoide','Ac',7,'f',232.04,'fest',11.72,1.3],#Th
          ['Protactinium',91,'Actinoide','Ac',7,'f',231.04,'fest',15.37,1.5],#Pa
          ['Uran',92,'Actinoide','Ac',7,'f',238.03,'fest',19.16,1.38],#U
          ['Neptunium',93,'Actinoide','Ac',7,'f',237.05,'fest',20.45,1.36],#Np
          ['Plutonium',94,'Actinoide','Ac',7,'f',244.06,'fest',19.82,1.28],#Pu
          ['Americium',95,'Actinoide','Ac',7,'f',243.06,'fest',13.67,1.3],#Am
          
          ['Curium',96,'Actinoide','Ac',7,'f',247.07,'fest',13.51,1.3],#Cm
          ['Berkelium',97,'Actinoide','Ac',7,'f',247,'fest',14.78,1.3],#Bk
          ['Californium',98,'Actinoide','Ac',7,'f',251,'fest',15.1,1.3],#Cf
          ['Einsteinium',99,'Actinoide','Ac',7,'f',252,'fest',8.84,'n.A'],#Es
          ['Fermium',100,'Actinoide','Ac',7,'f',257.10,'fest','n.A','n.A'],#Fm
          ['Medelevium',101,'Actinoide','Ac',7,'f',258,'fest','n.A','n.A'],#Md
          ['Nobelium',102,'Actinoide','Ac',7,'f',259,'fest','n.A.','n.A'],#No
          ['Lawrencium',103,'Actinoide','Ac',7,'f',266,'fest','n.A','n.A'],#Lr
          
          ['Rutherdordium',104,'Übergangsmetalle',4,7,'d',261.11,'fest',17.00,'n.A'],#Rf
          ['Dubnium',105,'Übergangsmetalle',5,7,'d',262.11,'n.A','n.A','n.A'],#Db
          ['Seaborgium',106,'Übergangsmetalle',6,7,'d',263.12,'n.A','n.A','n.A'],#Sg
          ['Bohrium',107,'Übergangsmetalle',7,7,'d',262.12,'n.A','n.A','n.A'],#Bh
          ['Hassium',108,'Übergangsmetalle',8,7,'d',265,'n.A','n.A','n.A'],#Hs
          ['Meitnerium',109,'Unbekannt',9,7,'d',268,'n.A','n.A','n.A'],#Mt
          ['Darmstadtium',110,'Unbekannt',10,7,'d',281,'n.A','n.A','n.A'],#Ds
          ['Roentgenium',111,'Unbekannt',11,7,'d',280,'n.A','n.A','n.A'],#Rg
          ['Copernicium',112,'Unbekannt',12,7,'d',277,'n.A','n.A','n.A'],#Cn

          ['Nihonium',113,'Unbekannt',13,7,'p',287,'n.A','n.A','n.A'],#Nh
          ['Flerovium',114,'Unbekannt',14,7,'p',289,'n.A','n.A','n.A'],#Fl
          ['Moscovium',115,'Unbekannt',15,7,'p',288,'n.A','n.A','n.A'],#Mc
          ['Livermorium',116,'Unbekannt',16,7,'p',293,'n.A','n.A','n.A'],#Lv
          ['Tenness',117,'Unbekannt',17,7,'p',292,'n.A','n.A','n.A'],#Ts
          ['Oganesson',118,'Unbekannt',18,7,'p',294,'fest',6.6,'n.A']#Og
          ]
kategorie_farben = {'Alkalimetalle' : '#fe6f61',
                    'Erdalkalimetalle':'#6791a7',
                    'Übergangsmetalle':'#83b8d0',
                    'Metalle':'#cae2ed',
                    'Halbmetalle':'#a7d6bc',
                    'Nichtmetalle':'#ffde66',
                    'Halogene':'#e9aa63',
                    'Edelgase':'#e29136',
                    'Unbekannt':'#cec0bf',
                    'Lanthanoide':'#696071',
                    'Actinoide':'#5b4c68'}
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            var = 2
            if c is 'La':
                c =Element.la_offset+var;Element.la_offset +=1
                r += self.offset
            if c is 'Ac':
                c =Element.ac_offset+var;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
import tkinter as tk
root = tk.Tk()
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,**kwargs)
class Element(tk.Frame):
    la_offset = 2;ac_offset=2;offset=2
    def __init__(self,master,symbol,**kwargs):
        tk.Frame.__init__(self,master,
                          relief = 'raised')
        self.kwargs = kwargs
        self.command= kwargs.pop('command', lambda:print('No command'))
        self.WIDTH,self.HEIGHT,self.BD = 100,100,3
        self.CMP = self.BD*2
        bg = kategorie_farben.get(kwargs.get('elementkategorie'))
        self.configure(width=self.WIDTH,height=self.HEIGHT,bd=self.BD,
                       bg=bg)
        self.grid_propagate(0)
        self.idx = tk.Label(self,text=kwargs.get('index'),bg=bg)
        self.u = tk.Label(self,text=kwargs.get('atommasse'),bg=bg)

        self.name = tk.Label(self,text=kwargs.get('name'),bg=bg)
        self.symb = tk.Label(self,text=symbol,font=('bold'),fg=self.get_fg(),bg=bg)
        
        self.e = tk.Label(self,text=kwargs.get('elektronegativität'),bg=bg)
        self.d = tk.Label(self,text=kwargs.get('dichte'),bg=bg)

        self.grid_columnconfigure(1, weight=2)
        self.grid_rowconfigure(1, weight=2)

        self.idx.grid(row=0,column=0,sticky='w')
        self.u.grid(row=0,column=2,sticky='e')
        
        mid_x = self.WIDTH/2-self.name.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.name.winfo_reqheight()/2
        offset= 15
        self.name.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP+offset)
        
        mid_x = self.WIDTH/2-self.symb.winfo_reqwidth()/2
        mid_y = self.HEIGHT/2-self.symb.winfo_reqheight()/2
        self.symb.place(in_=self,x=mid_x-self.CMP,y=mid_y-self.CMP-offset/2)
        
        self.e.grid(row=2,column=0,sticky='w')
        self.d.grid(row=2,column=2,sticky='e')

        r,c = kwargs.pop('periode'),kwargs.pop('gruppe')
        
        if c in ('La','Ac'):
            if c == 'La':
                c =Element.la_offset+Element.offset;Element.la_offset +=1
                r += self.offset
            if c == 'Ac':
                c =Element.ac_offset+Element.offset;Element.ac_offset +=1
                r += Element.offset
        
        self.grid(row=r,column=c,sticky='nswe')
        self.bind('<Enter>', self.in_active)
        self.bind('<Leave>', self.in_active)
        self.bind('<ButtonPress-1>', self.indicate)
        self.bind('<ButtonRelease-1>', self.execute)
        [child.bind('<ButtonPress-1>', self.indicate) for child in self.winfo_children()]
        [child.bind('<ButtonRelease-1>', self.execute) for child in self.winfo_children()]
    def in_active(self,event):
        if str(event.type) == 'Enter': self.flag = True
        if str(event.type) == 'Leave':
            self.flag = False;self.configure(relief='raised')
    def indicate(self,event):
        self.configure(relief='sunken')
    def execute(self,event):
        if self.flag: self.command();self.configure(relief='raised')
        else: self.configure(relief='raised')
    def get_fg(self):
        if self.kwargs.get('aggregatzustand') == 'fest': return 'black'
        if self.kwargs.get('aggregatzustand') == 'flüssig': return 'blue'
        if self.kwargs.get('aggregatzustand') == 'gasförmig': return 'red'
        if self.kwargs.get('aggregatzustand') == 'n.A': return 'grey'
def test():
    print('testing..')
        
for idx,symbol in enumerate(symbols):
    kwargs = {}
    for k,v in zip(keywords,values[idx]):
        kwargs.update({k:v})
    Element(root,symbol,command=test,**kwargs)

Deleting redundant `\author` and `\affiliation` fields in R papaja document

copy iconCopydownload iconDownload
---
title             : "Long title"
shorttitle        : "Short title"

author: 
  - name          : "First Author"
    affiliation   : "1"
  - name          : "Second Author"
    affiliation   : "1"
  - name          : "Third Author"
    affiliation   : "2"
  
affiliation:
  - id            : "1"
    institution   : "The University"
  - id            : "2"
    institution   : "The Other University"
    
documentclass     : apa7
classoption       : man
output            : papaja::apa6_docx
---

text text text text text text text text text.
-----------------------
---
title             : "Long title"
shorttitle        : "Short title"

documentclass     : apa7
classoption       : man
output            : papaja::apa6_pdf

header-includes:
  - \xpatchcmd{\authorsnames}{\newcounter{NumberOfAuthors}}{\setcounter{NumberOfAuthors}{0}}{}{}
  - \xpatchcmd{\authorsnames}{\newcounter{NumberOfSuperscripts}}{\setcounter{NumberOfSuperscripts}{0}}{}{}
  - \authorsnames[1, 2, 2]{first author, second author, third author}
  - \authorsaffiliations{{first affiliation}, {second affiliation}}
  - \renewcommand{\affiliation}[1]{}
---

text text text text text text text text text.

Why does calling the set function of a useState hook apply immediately in async functions?

copy iconCopydownload iconDownload
import { unstable_batchedUpdates } from "react-dom";
const updateState = () => {
    unstable_batchedUpdates(() => {
      console.log("\tupdating a starts.");
      setA(2);
      console.log("\tupdating a ends.");
      console.log("\tupdating b starts.");
      setB(12);
      console.log("\tupdating b ends.");
    });
  };

-----------------------
import { unstable_batchedUpdates } from "react-dom";
const updateState = () => {
    unstable_batchedUpdates(() => {
      console.log("\tupdating a starts.");
      setA(2);
      console.log("\tupdating a ends.");
      console.log("\tupdating b starts.");
      setB(12);
      console.log("\tupdating b ends.");
    });
  };

-----------------------
const [values, setValues] = useState({a: 1, b: 11});

setValues({a: 2, b: 12});

How to obtain smooth histogram after scaling image?

copy iconCopydownload iconDownload
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt

img = cv.imread('3NKTJ.jpg', cv.IMREAD_GRAYSCALE)
img_clahe = img.copy()
img_clahe = img_clahe/np.max(img_clahe)
img_clahe = (255*img_clahe).astype(np.uint8)

clahe = cv.createCLAHE(clipLimit=5, tileGridSize=(3,3))
img_clahe = clahe.apply(img_clahe)

img_s = img/255
img_s = img_s / np.max(img_s)
img_s = img_s*255

histogram = cv.calcHist([img], [0], None, [256], [0, 256])
histogram1 = cv.calcHist([img_s.astype('uint8')], [0], None, [256], [0, 256])
histogram2 = cv.calcHist([img_clahe.astype('uint8')], [0], None, [256], [0, 256])

plt.figure(dpi=100)
plt.title("Grayscale Histogram")
plt.xlabel("grayscale value")
plt.ylabel("pixels")

plt.plot(histogram, label='Original Image')  # <- or here
plt.plot(histogram1, label='Equalised Image')  # <- or here
plt.plot(histogram2, label='CLAHE Image')
plt.legend()
plt.show()
-----------------------
def apply_white_balance_single_channel(img, low_ratio=0.001, high_ratio=0.001):
    hist_size = 256
    hist = cv2.calcHist([img], [0], None, [hist_size], [0,hist_size])
    acc = np.cumsum(hist)
    low_limit = low_ratio * acc[-1] 
    high_limit = high_ratio * acc[-1]
    min_gray = 0
    while acc[min_gray] < low_limit and min_gray + 1 < hist_size: 
        min_gray += 1
    max_gray = hist_size - 1
    while acc[max_gray] >= acc[-1] - high_limit and max_gray > min_gray:
        max_gray -= 1
    input_range = max_gray - min_gray
    alpha = (hist_size - 1) / input_range
    beta = -min_gray * alpha
    return  (alpha * img + beta).clip(0,255).astype(np.uint8)

def apply_white_balance_multi_channel(img, low_ratio=0.001, high_ratio=0.001):
    channels = cv2.split(img)
    return cv2.merge([apply_white_balance_single_channel(ch, low_ratio, high_ratio) for ch in channels])
def apply_white_balance_multi_channel_min_max(img):
    channels = cv2.split(img)