Tuesday, October 20, 2020

Space Surfing Game Using HTML, CSS and JavaScript | Full Project With Source Code | Full Details

Macstock

In this post, My Friend Named Raj Patel Build An Amaing Project Using HTML CSS and JavaScript. This is an Awesome Space Surfing Game.

This Project, Not Belong to Me. This is Created By My Friend Raj Patel, you can Visit His Youtube Channel By Clicking the Given Button Below.

Visit Techno Guide Channel

How to Use :-

Open any folder and Make a file named "space_surfing_game.html". Now Copy the Source Code Given Below and Go back to the folder and Open the "space_surfing_game.html" using Notepad, Now Paste the code there and save the file and close it. Now just open the file using Any Browser you use.

Source Code Here :-



<!doctype html>
<html>

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Dots Space</title>
  <style>
    html {
      color: #000;
      background: #222222;
    }

    a {
      cursor: pointer;
    }

    html,
    body,
    div,
    dl,
    dt,
    dd,
    ul,
    ol,
    li,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    pre,
    code,
    form,
    fieldset,
    legend,
    input,
    textarea,
    p,
    blockquote,
    th,
    td {
      margin: 0;
      padding: 0;
    }

    table {
      border-collapse: collapse;
      border-spacing: 0;
    }

    fieldset,
    img {
      border: 0;
    }

    address,
    caption,
    cite,
    code,
    dfn,
    em,
    strong,
    th,
    var {
      font-style: normal;
      font-weight: normal;
    }

    li {
      list-style: none;
    }

    caption,
    th {
      text-align: left;
    }

    /* h1,h2,h3,h4,h5,h6{font-size:100%;} */
    q:before,
    q:after {
      content: '';
    }

    abbr,
    acronym {
      border: 0;
      font-variant: normal;
    }

    sup {
      vertical-align: text-top;
    }

    sub {
      vertical-align: text-bottom;
    }

    input,
    textarea,
    select {
      font-family: inherit;
      font-size: inherit;
      font-weight: inherit;
      outline-style: none;
      outline-width: 0pt;
    }

    legend {
      color: #000;
    }

    a:focus,
    object,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
      -moz-outline-style: none;
      border: 0px;
    }

    /*input[type="Submit"]{cursor:pointer;}*/
    strong {
      font-weight: bold;
    }

    body {
      overflow: hidden;
      font-family: Helvetica, Arial, sans-serif;
      color: #333333;
      font-size: 11px;
      background-color: #222222;
    }

    canvas {
      background-color: #111111;
    }

    .ui {
      font-family: Arial, Helvetica, sans-serif;
      font-size: 10px;
      color: #999999;
      text-align: left;
      padding: 8px;
      background-color: rgba(0, 0, 0, 0.5);
      position: absolute;
      z-index: 2;
      margin: 0;
    }

    #message {
      padding: 16px;
    }

    #message p {
      color: lime;
      font-size: 12px;
      animation: blink 880ms ease-in-out infinite;
    }

    #status {
      width: 100%;
      height: 15px;
      padding: 8px;
      display: none;
    }

    #status span {
      color: dodgerblue;
      font-weight: bold;
      margin-right: 5px;
    }

    #title {
      margin-bottom: 20px;
      color: #eeeeee;
    }

    .ui ul {
      margin: 10px 0 10px 0;
    }

    .ui a {
      outline: none;
      font-family: Arial, Helvetica, sans-serif;
      font-size: 38px;
      text-decoration: none;
      color: #bbbbbb;
      padding: 2px;
      display: block;
      background: goldenrod;
      border-radius: 12px;
      text-align: center;
    }

    .ui a:hover {
      color: #000;
      background-color: #4bde35;
    }

    @keyframes blink {
      0% {
        color: lime;
      }

      100% {
        color: transparent;
      }
    }
  </style>
</head>

<body>
  <canvas id="world"></canvas>
  <div id="status" class="ui"></div>
  <div id="message" class="ui">
    <h2 id="title"></h2>
    <ul>
      <li>1. Avoid RED dots.</li>
      <br>
      <li>2. Touch GREEN dots for invulnerability.</li>
      <br>
      <li>3. Use invulnerability to destroy RED dots.</li>
      <br>
      <li>4. Score EXTRA points by moving around a lot.</li>
      <br>
      <li>5. STAY ALIVE !</li>
    </ul>
    <a href="#" id="startButton">Start</a>
    <br>
    <p>Good Luck...</p>
  </div>
  <script type="text/javascript">
    Spacedots = new function () {

      var isMobile = (navigator.userAgent.toLowerCase().indexOf('android') != -1) || (navigator.userAgent.toLowerCase().indexOf('iphone') != -1);

      var SCREEN_WIDTH = window.innerWidth;
      var SCREEN_HEIGHT = window.innerHeight;

      var canvas;
      var context;

      var status;
      var message;
      var title;
      var startButton;

      var enemies = [];
      var boosts = [];
      var particles = [];
      var player;

      var mouseX = (window.innerWidth - SCREEN_WIDTH);
      var mouseY = (window.innerHeight - SCREEN_HEIGHT);
      var mouseIsDown = false;

      var playing = false;
      var score = 0;
      var time = 0;

      var velocity = { x: -1.5, y: 1 };
      var difficulty = 1;

      this.init = function () {

        canvas = document.getElementById('world');
        status = document.getElementById('status');
        message = document.getElementById('message');
        title = document.getElementById('title');
        startButton = document.getElementById('startButton');

        if (canvas && canvas.getContext) {
          context = canvas.getContext('2d');

          // Register event listeners
          document.addEventListener('mousemove', documentMouseMoveHandler, false);
          document.addEventListener('mousedown', documentMouseDownHandler, false);
          document.addEventListener('mouseup', documentMouseUpHandler, false);
          canvas.addEventListener('touchstart', documentTouchStartHandler, false);
          document.addEventListener('touchmove', documentTouchMoveHandler, false);
          document.addEventListener('touchend', documentTouchEndHandler, false);
          window.addEventListener('resize', windowResizeHandler, false);
          startButton.addEventListener('click', startButtonClickHandler, false);

          player = new Player();

          windowResizeHandler();

          setInterval(loop, 1000 / 70);
        }
      };

      function startButtonClickHandler(event) {
        event.preventDefault();

        if (playing == false) {
          playing = true;

          enemies = [];
          boosts = [];
          score = 0;
          difficulty = 1;

          player.trail = [];
          player.position.x = mouseX;
          player.position.y = mouseY;
          player.boost = 0;

          message.style.display = 'none';
          status.style.display = 'block';

          time = new Date().getTime();
        }
      }

      function gameOver() {
        playing = false;

        message.style.display = 'block';

        title.innerHTML = 'Game Over! (' + Math.round(score) + ' points)';
      }

      function documentMouseMoveHandler(event) {
        mouseX = event.clientX - (window.innerWidth - SCREEN_WIDTH) * .5 - 10;
        mouseY = event.clientY - (window.innerHeight - SCREEN_HEIGHT) * .5 - 10;
      }

      function documentMouseDownHandler(event) {
        mouseIsDown = true;
      }

      function documentMouseUpHandler(event) {
        mouseIsDown = false;
      }

      function documentTouchStartHandler(event) {
        if (event.touches.length == 1) {
          event.preventDefault();

          mouseX = event.touches[0].pageX - (window.innerWidth - SCREEN_WIDTH) * .5;
          mouseY = event.touches[0].pageY - (window.innerHeight - SCREEN_HEIGHT) * .5;

          mouseIsDown = true;
        }
      }

      function documentTouchMoveHandler(event) {
        if (event.touches.length == 1) {
          event.preventDefault();

          mouseX = event.touches[0].pageX - (window.innerWidth - SCREEN_WIDTH) * .5;
          mouseY = event.touches[0].pageY - (window.innerHeight - SCREEN_HEIGHT) * .5;
        }
      }

      function documentTouchEndHandler(event) {
        mouseIsDown = false;
      }

      function windowResizeHandler() {
        SCREEN_WIDTH = window.innerWidth;
        SCREEN_HEIGHT = window.innerHeight;

        canvas.width = SCREEN_WIDTH;
        canvas.height = SCREEN_HEIGHT;

        var cvx = (window.innerWidth - SCREEN_WIDTH) * .5;
        var cvy = (window.innerHeight - SCREEN_HEIGHT) * .5;

        canvas.style.position = 'absolute';
        canvas.style.left = cvx + 'px';
        canvas.style.top = cvy + 'px';

        message.style.left = cvx + 'px';
        message.style.top = cvy + 200 + 'px';
      }

      function createParticles(position, spread, color) {
        var q = 10 + (Math.random() * 15);

        while (--q >= 0) {
          var p = new Particle();
          p.position.x = position.x + (Math.sin(q) * spread);
          p.position.y = position.y + (Math.cos(q) * spread);
          p.velocity = { x: -4 + Math.random() * 8, y: - 4 + Math.random() * 8 };
          p.alpha = 1;

          particles.push(p);
        }
      }

      function loop() {

        context.clearRect(0, 0, canvas.width, canvas.height);

        var svelocity = { x: velocity.x * difficulty, y: velocity.y * difficulty };

        var i, j, ilen, jlen;

        if (playing) {
          difficulty += 0.0008;

          pp = player.clonePosition();

          player.position.x += (mouseX - player.position.x) * 0.13;
          player.position.y += (mouseY - player.position.y) * 0.13;

          score += 0.4 * difficulty;
          score += player.distanceTo(pp) * 0.1;

          player.boost = Math.max(player.boost - 1, 0);

          if (player.boost > 0 && (player.boost > 100 || player.boost % 3 != 0)) {
            context.beginPath();
            context.fillStyle = '#167a66';//couleur interne au stade augmenter
            context.strokeStyle = 'yellow';//couleur de la bordure au stade augmenter
            context.arc(player.position.x, player.position.y, player.size * 2, 0, Math.PI * 2, true);
            context.fill();
            context.stroke();
          }

          player.trail.push(new Point(player.position.x, player.position.y));

          context.beginPath();
          context.strokeStyle = 'gold';// couleur du fil
          context.lineWidth = 2;

          for (i = 0, ilen = player.trail.length; i < ilen; i++) {
            p = player.trail[i];

            context.lineTo(p.position.x, p.position.y);

            p.position.x += svelocity.x;
            p.position.y += svelocity.y;
          }

          context.stroke();
          context.closePath();

          if (player.trail.length > 60) {
            player.trail.shift();
          }

          context.beginPath();
          context.fillStyle = 'orange';//couleur du noyau au stade normal
          context.arc(player.position.x, player.position.y, player.size / 2, 0, Math.PI * 2, true);
          context.fill();
        }

        if (playing && (player.position.x < 0 || player.position.x > SCREEN_WIDTH || player.position.y < 0 || player.position.y > SCREEN_HEIGHT)) {
          gameOver();
        }

        for (i = 0; i < enemies.length; i++) {
          p = enemies[i];

          if (playing) {
            if (player.boost > 0 && p.distanceTo(player.position) < ((player.size * 4) + p.size) * 0.5) {
              createParticles(p.position, 10);
              enemies.splice(i, 1);
              i--;
              score += 10;
              continue;
            }
            else if (p.distanceTo(player.position) < (player.size + p.size) * 0.5) {
              createParticles(player.position, 10);
              gameOver();
            }
          }

          context.beginPath();
          context.fillStyle = 'red';//couleur des balles ennemies diminue
          context.arc(p.position.x, p.position.y, p.size / 2, 0, Math.PI * 2, true);
          context.fill();

          p.position.x += svelocity.x * p.force;
          p.position.y += svelocity.y * p.force;

          if (p.position.x < 0 || p.position.y > SCREEN_HEIGHT) {
            enemies.splice(i, 1);
            i--;
          }
        }

        for (i = 0; i < boosts.length; i++) {
          p = boosts[i];

          if (p.distanceTo(player.position) < (player.size + p.size) * 0.5 && playing) {
            player.boost = 300;

            for (j = 0; j < enemies.length; j++) {
              e = enemies[j];

              if (e.distanceTo(p.position) < 100) {
                createParticles(e.position, 10);
                enemies.splice(j, 1);
                j--;
                score += 10;
              }
            }
          }

          context.beginPath();
          context.fillStyle = '#00ffcc';//couleur de la balle de point augmente
          context.arc(p.position.x, p.position.y, p.size / 2, 0, Math.PI * 2, true);
          context.fill();

          p.position.x += svelocity.x * p.force;
          p.position.y += svelocity.y * p.force;

          if (p.position.x < 0 || p.position.y > SCREEN_HEIGHT || player.boost != 0) {
            boosts.splice(i, 1);
            i--;
          }
        }

        if (enemies.length < 25 * difficulty) {
          enemies.push(positionNewOrganism(new Enemy()));
        }

        if (boosts.length < 1 && Math.random() > 0.997 && player.boost == 0) {
          boosts.push(positionNewOrganism(new Boost()));
        }

        for (i = 0; i < particles.length; i++) {
          p = particles[i];

          p.velocity.x += (svelocity.x - p.velocity.x) * 0.04;
          p.velocity.y += (svelocity.y - p.velocity.y) * 0.04;

          p.position.x += p.velocity.x;
          p.position.y += p.velocity.y;

          p.alpha -= 0.02;

          context.fillStyle = 'red' + Math.max(p.alpha, 0) + ')';
          context.fillRect(p.position.x, p.position.y, 1, 1);

          if (p.alpha <= 0) {
            particles.splice(i, 1);
          }
        }

        if (playing) {
          scoreText = 'Score: <span>' + Math.round(score) + '</span>';
          scoreText += ' Time: <span>' + Math.round(((new Date().getTime() - time) / 1000) * 100) / 100 + 's</span>';
          status.innerHTML = scoreText;
        }
      }

      function positionNewOrganism(p) {
        if (Math.random() > 0.5) {
          p.position.x = Math.random() * SCREEN_WIDTH;
          p.position.y = -20;
        }
        else {
          p.position.x = SCREEN_WIDTH + 60;
          p.position.y = (-SCREEN_HEIGHT * 0.2) + (Math.random() * SCREEN_HEIGHT * 1.2);
        }
        return p;
      }
    };
    /****/
    function Point(x, y) {
      this.position = { x: x, y: y };
    }
    Point.prototype.distanceTo = function (p) {
      var dx = p.x - this.position.x;
      var dy = p.y - this.position.y;
      return Math.sqrt(dx * dx + dy * dy);
    };
    Point.prototype.clonePosition = function () {
      return { x: this.position.x, y: this.position.y };
    };
    /****/
    function Player() {
      this.position = { x: 0, y: 0 };
      this.trail = [];
      this.size = 8;
      this.boost = 0;
    }
    Player.prototype = new Point();
    /****/
    function Enemy() {
      this.position = { x: 0, y: 0 };
      this.size = 6 + (Math.random() * 4);
      this.force = 1 + (Math.random() * 0.4);
    }
    Enemy.prototype = new Point();
    /****/
    function Boost() {
      this.position = { x: 0, y: 0 };
      this.size = 10 + (Math.random() * 8);
      this.force = 1 + (Math.random() * 0.4);
    }
    Boost.prototype = new Point();
    /****/
    function Particle() {
      this.position = { x: 0, y: 0 };
      this.force = 1 + (Math.random() * 0.4);
      this.color = '#ff0000';
    }
    Particle.prototype = new Point();

    Spacedots.init();
  </script>
</body>

<html>
        

Hope You will Like it

Monday, October 19, 2020

[SOLVED] OS Error 09 : Bad File Descriptor and Could Not Read From src/future/backports/http/cookies.py | Fully Explained in English

Macstock

In this post, I have Managed to Explain you How to Fix OS Error Bad File Descriptor or Could not Read From src/future/backports/http/cookies.py Errors

So, If you Like the Post, and your Error is Fixed After Reading the post, then Please Comment Down Below.


For Better Understanding You Should Watch the Full Video [Explained In Hindi Language] By Clicking the Video Button Given Below


Steps to Fix this Error :-

Step 1 : Check that you have Setuptools Installed In your Scripts Folder Or Not.

How to Check :-

#1 : Open Command Prompt or Windows Powershell.

#2 : Type "python".

You Will See This Type of Dialog Box :-

#3 : Type "import setuptools".

If it Returns Nothing, Like Given Below in Image, then Setuptools is Installed in Your PC.

If it Returns a TraceBack Error, then Setuptools is not Installed in your PC.

If Setuptools is Not Installed in Your PC :-

#1 Open Command Prompt or Windows Powershell.

#2 Type "pip install setuptools".

Then Setuptools Will Be Installed.

Step 2: Go to pypi.org and Type the Package Name in the Search Bar, In which You are Facing the Error. After Typing, Press Enter.

Step 3: You Will See Your Package Name Listed, Just Click on it.

Step 4: Now Click on the Download Files option, on the Left Side of the Page.

Step 5: Now you will see Many Files In it, Click on the .tar.gz file, and It will Start Downloading.

Step 6: After Downloading Complete, Navigate to Your Downlaods Folder using Command Prompt.

How to Navigate to Downloads Folder Using Command Prompt :-

#1 : Open Command Prompt, Your Command Prompt will defaultly Navigate to C:\Users\YourPCName, like Shown in the Image below.

#2 : Now type "cd Downloads", and You Will Navigate inside The Downlaods Folder.

Step 7: After Navigating to Downloads Folder, Minimize Command Prompt and go to Downlaods Folder and Right Click the .tar.gz file that You Have Downloaded and Extract the .tar.gz file Using WinRar.

Step 8: Open Command Prompt and Now Navigate to the Folder Formed After Extracting the .tar.gz file, by typing "cd <FolderName>".

Step 9: Type "python setup.py install". And Your Package Will Be Installed Successfully.

Thursday, October 15, 2020

Tic-Tac-Toe Android App | Android Studio | Full Project With Source Code | Download .apk File on Phone

Macstock

In this Post, I have Managed to Show you how i Made a Tic-Tac-Toe Android App Using Android Studio.

It is a little bit comlex, so if you are not a Android Developer then You Should Download the .apk File of this App to Use this in your Android Device

Want to Install It without Android Studio In your Phone, Download from the link :-


For Those, who want to Build OwnSelf :-

I have Used Some Images in this Project, download them and Paste in Your Project Drawable Folder and Drawable x24 Folder

[MainActivity.java] Source Code :-


package com.macstockofficial.project2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private Button button;

    public void exit_game(View view) {
        Intent homeIntent = new Intent(Intent.ACTION_MAIN);
        homeIntent.addCategory( Intent.CATEGORY_HOME );
        homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(homeIntent);
    }

    public void startbtn(View view) {
        Toast.makeText(this, "Starting Tic-Tac-Toe By Kunal Sir, Wait a Sec...", Toast.LENGTH_SHORT).show();
        openActivity2();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void openActivity2() {
        Intent intent = new Intent(this, SecondActivity.class);
        startActivity(intent);
    }
}
    

[SecondActivity.java] Source Code :-


package com.macstockofficial.project2;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class SecondActivity extends AppCompatActivity {
// Player Representation
    // 0 = X
    // 1 = O
    // 2 = Null

    public void backftn(View view) {
        Toast.makeText(this, "Moving to HomePage Sir...", Toast.LENGTH_SHORT).show();
        openActivity8();
    }

    public void openActivity8() {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
    }

    public void restart(View view) {
        reset(view);
    }

    boolean gameActive = true;
    int activeplayer = 0;
    int[] gamestate = {2, 2, 2, 2, 2, 2, 2, 2, 2};
    int[][] winPositions = {{0,1,2}, {3,4,5}, {6,7,8},
            {0,3,6}, {1,4,7}, {2,5,8},
            {0,4,8}, {2,4,6}};

    public void tapthebtn(View view) {
        ImageView img = (ImageView) view;
        int tappedImage = Integer.parseInt(img.getTag().toString());
        if (gameActive!=true) {
            reset(view);
        }
        if (gamestate[tappedImage] == 2 && gameActive==true) {
            gamestate[tappedImage] = activeplayer;
            img.setTranslationY(-1000f);
            if (activeplayer == 0) {
                img.setImageResource(R.drawable.x);
                activeplayer = 1;
                TextView status = findViewById(R.id.status);
                status.setText("Its O's Turn | Tap to Play!");
            } else {
                img.setImageResource(R.drawable.o);
                activeplayer = 0;
                TextView status = findViewById(R.id.status);
                status.setText("Its X's Turn | Tap to Play!");
            }
            img.animate().translationYBy(1000f).setDuration(200);
        }
        // Check if Player Has Won
        for(int[] winPosition: winPositions) {
            if (gamestate[winPosition[0]] == gamestate[winPosition[1]] &&
                    gamestate[winPosition[1]] == gamestate[winPosition[2]] &&
                    gamestate[winPosition[0]]!=2) {
                String winnerStr;
                gameActive = false;
                if (gamestate[winPosition[0]] == 0) {
                    winnerStr = "X Has Won the Game";
                }
                else{
                    winnerStr = "O Has Won the Game";
                }
                TextView status = findViewById(R.id.status);
                status.setText(winnerStr);
            }
        }
    }

    public void reset(View view) {
        gameActive = true;
        activeplayer = 0;
        for(int i=0; i<gamestate.length; i++) {
            gamestate[i] = 2;
        }
        ((ImageView)findViewById(R.id.imageView0)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView1)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView2)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView3)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView4)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView5)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView6)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView7)).setImageResource(0);
        ((ImageView)findViewById(R.id.imageView8)).setImageResource(0);

        TextView status = findViewById(R.id.status);
        status.setText("Its X's Turn | Tap to Play!");
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
    }
}
    

Layout Source Codes

[activity_main.xml] Source Code :-


    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="115dp"
        android:layout_height="113dp"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:contentDescription="@string/TODO"
        app:layout_constraintBottom_toTopOf="@+id/textView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.797"
        app:srcCompat="@android:drawable/ic_menu_edit" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/sub_title"
        android:textColor="#CC1D1D"
        android:textSize="24sp"
        app:fontFamily="casual"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.496"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.466"
        tools:fontFamily="casual" />

    <Button
        android:id="@+id/button"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="startbtn"
        android:text="@string/start_btn"
        android:textAppearance="@style/TextAppearance.AppCompat.Body2"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        app:layout_constraintVertical_bias="0.114" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/creator_name"
        android:textColor="@android:color/holo_green_dark"
        android:textSize="14sp"
        app:fontFamily="serif"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button"
        app:layout_constraintVertical_bias="0.462"
        tools:fontFamily="serif" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/description"
        android:textSize="18sp"
        app:fontFamily="cursive"
        app:layout_constraintBottom_toTopOf="@+id/textView2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.481"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView"
        app:layout_constraintVertical_bias="0.622"
        tools:fontFamily="cursive" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-condensed"
        android:text="@string/Information"
        app:layout_constraintBottom_toTopOf="@+id/imageView"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.726"
        tools:fontFamily="sans-serif-condensed" />

    <Button
        android:id="@+id/button4"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="exit_game"
        android:text="@string/close_btn"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView2"
        app:layout_constraintVertical_bias="0.382" />

</androidx.constraintlayout.widget.ConstraintLayout>
    

[activity_second.xml] Source Code :-


    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SecondActivity">

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/content_description"
        android:text="@string/TextView"
        android:textColor="#D53E3E"
        android:textSize="24sp"
        app:fontFamily="cursive"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.38"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.071"
        tools:fontFamily="cursive" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="519dp"
        android:layout_height="311dp"
        android:contentDescription="@string/content_description"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.678"
        app:srcCompat="@drawable/grid" />

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="0dp"
        android:layout_height="260dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="@+id/imageView"
        app:layout_constraintEnd_toEndOf="@+id/imageView"
        app:layout_constraintStart_toStartOf="@+id/imageView"
        app:layout_constraintTop_toTopOf="@+id/imageView">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imageView0"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="52pt"
                android:layout_marginTop="15sp"
                android:layout_marginRight="1pt"
                android:layout_marginBottom="15sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="5sp"
                android:tag="0" />

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="5sp"
                android:layout_marginBottom="5sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="18sp"
                android:tag="1"
                tools:paddingBottom="5sp" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="5pt"
                android:layout_marginTop="15sp"
                android:layout_marginRight="50pt"
                android:layout_marginBottom="15sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:paddingRight="15sp"
                android:tag="2" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="52pt"
                android:layout_marginTop="15sp"
                android:layout_marginBottom="15sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="5sp"
                android:tag="3" />

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="5sp"
                android:layout_marginBottom="5sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="18sp"
                android:paddingBottom="5sp"
                android:tag="4" />

            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="1pt"
                android:layout_marginTop="15sp"
                android:layout_marginRight="52pt"
                android:layout_marginBottom="10sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="5sp"
                android:tag="5" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/imageView6"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="50pt"
                android:layout_marginTop="15sp"
                android:layout_marginRight="1pt"
                android:layout_marginBottom="15sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="5sp"
                android:tag="6" />

            <ImageView
                android:id="@+id/imageView7"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="5sp"
                android:layout_marginBottom="5sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="18sp"
                android:paddingBottom="5sp"
                android:tag="7" />

            <ImageView
                android:id="@+id/imageView8"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="1pt"
                android:layout_marginTop="15sp"
                android:layout_marginRight="52pt"
                android:layout_marginBottom="15sp"
                android:layout_weight="1"
                android:onClick="tapthebtn"
                android:padding="5sp"
                android:tag="8" />
        </LinearLayout>

    </LinearLayout>

    <TextView
        android:id="@+id/status"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:fontFamily="sans-serif-black"
        android:text="Its X's Turn | Tap to Play!"
        android:textColor="#FF5722"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView"
        app:layout_constraintVertical_bias="0.517"
        tools:fontFamily="sans-serif-black" />

    <Button
        android:id="@+id/button2"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="restart"
        android:text="@string/restart"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/button3"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.171" />

    <Button
        android:id="@+id/button3"
        style="@style/Widget.AppCompat.Button.Colored"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="backftn"
        android:text="@string/back_btn"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.193"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.171" />

</androidx.constraintlayout.widget.ConstraintLayout>
    

Hope You Will Like the Project

Friday, September 25, 2020

Currency Convertor Using Python | Source Code | LIbararies to Install | Other Details

Macstock

In this post, I have managed to Build an Amazing Currency Convertor Using Python Tkinter. The App has an Fallback that is not big problem, that Zimbabwe Dollar cannot be Used. We are Working On it and Soon it Will be Used.

I have Used Only Two Modules in this Projects and One Pre Installed Module Named TKinter. So If you want to Download this Program, you can download to and the Downloaded File WIll be Installed in your Computer.

For Better Understanding You Should Watch the Videos[Explained in Hindi Language]Step-By-Step By Clicking the Video Buttons Given Below


Part 1

Part 2

Part 3

Want to Install It without Python, Download from these links :-

Python Libararies To Install Before Copying Codes

Simply Open Your Terminal [You can Use 'Command Prompt' Or 'Windows Powershell' also. And Run These Commands there to Install These Packages.

pip install google-currency

pip install json


I have Used One File Named "ind.txt" in My Code, Here is the Link to Download the File :

Souce Code Here :-


from tkinter import *
from tkinter import messagebox
from tkinter.ttk import Combobox
from google_currency import convert
import json


root = Tk()
root.geometry("600x400")
root.title("Currency Convertor By Kunal")
# root.iconbitmap("Your Icon.ico")
root.config(bg="lightgreen")
root.resizable(False, False)

with open('ind.txt') as k:
    lines = k.readlines()


currencyDict = {}
for line in lines:
    parsed = line.split("\t")
    currencyDict[parsed[1]] = parsed[2]
    
def funtiol():
    try:
        lan = currentbox.get()
        paol = currencyDict[lan]
        lap = currentbox2.get()
        olop = currencyDict[lap]
        serial = varb.get()
        rider = convert(paol, olop, serial)
        json_dict = json.loads(rider)
        semibox = json_dict["amount"]
        var1.set(semibox)
    except:
        semiboss = messagebox.askretrycancel('A Problem Has Been Occured', 'Please Check Your Internet Connection, Change Your Currency or Amount you Have Entered')  
        if (semiboss==True):
            return "None"


Title = Label(root, text="Currency Convertor By You", font=('ubuntu', 20, "italic"), bg="lightgreen", fg="red")
Title.place(x=120, y=10)

Lable1 = Label(root, text="Enter the Amount to Convert :- ", font=('ubuntu', 15, "bold"), bg="lightgreen", fg="brown")
Lable1.place(x=10, y=70)

varb = IntVar()
MainBox = Entry(root, textvar=varb, bg="grey", fg="lightblue", width=25, font=('ubuntu', 15, "bold"))
MainBox.place(x=315, y=70)

Label2 = Label(root, text="Select the Currency to Convert Your Amount From :-",  font=('ubuntu', 10, "bold"), bg="lightgreen", fg="blue")
Label2.place(x=10, y=140)

Label3 = Label(root, text="Select the Currency to Convert Your Amount to :-",  font=('ubuntu', 10, "bold"), bg="lightgreen", fg="blue")
Label3.place(x=10, y=180)

Lable4 = Label(root, text="Converted Amount Here :- ", font=('ubuntu', 15, "bold"), bg="lightgreen", fg="brown")
Lable4.place(x=10, y=300)

btn1 = Button(root, text="Convert", font=('ubuntu', 15, "bold"),  command=funtiol,  bg="lightblue", fg="orange", relief=RAISED,\
                         cursor="hand2")
btn1.place(x=250, y=230)

var1 = IntVar() 
mainint = Entry(root, textvariable=var1, fg="orange", width=28, font=('ubuntu', 15, "bold"), state="readonly")
mainint.place(x=270, y=300)

footer = Label(root, text="Build and Developed By You", font=('ubuntu', 15, "italic"), bg="lightgreen", fg="grey")
footer.place(x=120, y=360)

#Combobox 1 
currentbox = StringVar()
combo_box = Combobox(root, width=30, textvar=currentbox, state="readonly")
combo_box['values'] = [item for item in currencyDict.keys()]
combo_box.current(4)
combo_box.place(x=360, y=140)

#Combobox 2
currentbox2 = StringVar()
combotake = Combobox(root, width=30, textvar=currentbox2, state="readonly")
combotake['values'] = [item for item in currencyDict.keys()]
combotake.current(0)
combotake.place(x=360, y=180)


root.mainloop()
    

Tuesday, September 22, 2020

Simple Calculator Using Python | Source Code | LIbararies to Install | Other Details

Macstock

In this Post, I have managed to Build an Amazing Calculator Using Python Tkinter. If you like it then please Comment Down Below.

It does not require any Type of Library Installation, Just Requires Tkinter Which is Pre Installed in Python Package

Want to Install It without Python, Download from these links :-

Souce Code Here :-



# Libaries Imported
from tkinter import *

#Main Configurations
root = Tk()
root.geometry("400x440")
root.configure(bg="grey")
root.title("Your Name Calculator")
root.iconbitmap("calc.ico")
root.resizable(False, False)

#Functions to Run

def press(event):
    global varname1
    text = event.widget.cget("text")
    if text == "=":
        if varname1.get().isdigit():
            value = int(varname1.get())
        else:
            value = eval(mainbox.get())

        varname1.set(value)
        mainbox.update()
    elif text == "C":
        varname1.set("")
        mainbox.update()
    else:
        varname1.set(varname1.get() + text)
        mainbox.update()
# Main Box
varname1 = StringVar()
mainbox = Entry(root, width="17", textvar=varname1, state="readonly", font=('ubuntu', 30, 'bold'))
mainbox.place(x=10, y=2)

# Buttons to Add 

btn9 = Button(root, text="9",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'),)
btn9.place(x=15, y=60)
btn9.bind("<Button-1>",  press)

btn8 = Button(root, text="8",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn8.place(x=115, y=60)
btn8.bind("<Button-1>",  press)

btn7 = Button(root, text="7",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn7.place(x=215, y=60)
btn7.bind("<Button-1>",  press)

btn6 = Button(root, text="6",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn6.place(x=15, y=150)
btn6.bind("<Button-1>",  press)

btn5 = Button(root, text="5",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn5.place(x=115, y=150)
btn5.bind("<Button-1>",  press)

btn4 = Button(root, text="4",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn4.place(x=215, y=150)
btn4.bind("<Button-1>",  press)

btn3 = Button(root, text="3",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn3.place(x=15, y=240)
btn3.bind("<Button-1>",  press)

btn2 = Button(root, text="2",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn2.place(x=115, y=240)
btn2.bind("<Button-1>",  press)

btn1 = Button(root, text="1",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btn1.place(x=215, y=240)
btn1.bind("<Button-1>",  press)

btnstar = Button(root, text="*",padx=15, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btnstar.place(x=115, y=330)
btnstar.bind("<Button-1>",  press)

btnslash = Button(root, text="/",padx=17, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btnslash.place(x=215, y=330)
btnslash.bind("<Button-1>",  press)

btnadd = Button(root, text="+",padx=13, bg="pink", fg="white", font=('ubuntu', 20, 'bold'))
btnadd.place(x=15, y=330)
btnadd.bind("<Button-1>",  press)

btnminus = Button(root, text="-",padx=15, bg="pink", fg="white",  font=('ubuntu', 20, 'bold'))
btnminus.place(x=315, y=330)
btnminus.bind("<Button-1>",  press)

btnC = Button(root, text="C",padx=9, pady=15, bg="red", fg="white", font=('ubuntu', 20, 'bold'))
btnC.place(x=315, y=230)
btnC.bind("<Button-1>",  press)

btnequal = Button(root, text="=",padx=11, pady=48, bg="blue", fg="white", font=('ubuntu', 20, 'bold'))
btnequal.place(x=315, y=60)
btnequal.bind("<Button-1>",  press)

Label1 = Label(root, text="Designed and Developed By Your Name", fg="yellow", bg="grey", font=('ubuntu', 15, 'bold'))
Label1.place(x=3, y=400)



root.mainloop()
    

Friday, September 18, 2020

Text Translator Using Python | Source Code | Libaries to Install | Other Details | Full Details

Macstock

In This Post, I Have Managed to Build an Amazing Translator Tool Using Python Tkinter, If You Like it the please Comment down below.

It Supports All Languages Translation, So do not Worry if you not Want to Translate In Hindi or You are not an Indian.

Want to Install It without Python, Download from these links :-

Python Libararies To Install Before Copying Codes

Simply Open Your Terminal [You can Use 'Command Prompt' Or 'Windows Powershell' also. And Run These Commands there to Install These Packages.

pip install playsound

pip install tkinter

pip install pygame

pip install textblob

Souce Code Here :-



# Libraries Imported
from playsound import playsound
from tkinter import *
from tkinter import messagebox
import winsound
from tkinter.ttk import Combobox
import pygame
from textblob import *

# Main Configurations
root = Tk()
root.geometry("800x400")
root.title("Kunal Translator")
root.resizable(False, False)
root.configure(bg="grey")
# root.iconbitmap("Your Icon.ico")
lan_dict = {'afrikaans': 'af', 'albanian': 'sq', 'amharic': 'am', 'arabic': 'ar', 'armenian': 'hy', 'azerbaijani': 'az', 'basque': 'eu', 'belarusian': 'be', 
'bengali': 'bn', 'bosnian': 'bs', 'bulgarian': 'bg', 'catalan': 'ca', 'cebuano': 'ceb', 'chichewa': 'ny', 'chinese (simplified)': 'zh-cn', 'chinese (traditional)': 'zh-tw', 'corsican': 'co', 'croatian': 'hr', 'czech': 'cs', 'danish': 'da', 'dutch': 'nl', 'english': 'en', 'esperanto': 'eo', 'estonian': 'et', 'filipino': 'tl', 'finnish': 'fi', 'french': 'fr', 'frisian': 'fy', 'galician': 'gl', 'georgian': 'ka', 'german': 'de', 'greek': 
'el', 'gujarati': 'gu', 'haitian creole': 'ht', 'hausa': 'ha', 'hawaiian': 'haw', 'hebrew': 'he', 'hindi': 'hi', 'hmong': 'hmn', 'hungarian': 'hu', 'icelandic': 'is', 'igbo': 'ig', 'indonesian': 'id', 'irish': 'ga', 'italian': 'it', 'japanese': 'ja', 'javanese': 'jw', 'kannada': 'kn', 'kazakh': 'kk', 'khmer': 'km', 'korean': 'ko', 'kurdish (kurmanji)': 'ku', 'kyrgyz': 'ky', 'lao': 'lo', 'latin': 'la', 'latvian': 'lv', 'lithuanian': 'lt', 'luxembourgish': 'lb', 'macedonian': 'mk', 'malagasy': 'mg', 'malay': 'ms', 'malayalam': 'ml', 'maltese': 'mt', 'maori': 'mi', 'marathi': 'mr', 'mongolian': 'mn', 'myanmar (burmese)': 'my', 'nepali': 'ne', 'norwegian': 'no', 'odia': 'or', 'pashto': 'ps', 'persian': 'fa', 'polish': 'pl', 
'portuguese': 'pt', 'punjabi': 'pa', 'romanian': 'ro', 'russian': 'ru', 'samoan': 'sm', 'scots gaelic': 'gd', 'serbian': 'sr', 'sesotho': 'st', 'shona': 'sn', 'sindhi': 'sd', 'sinhala': 'si', 'slovak': 'sk', 'slovenian': 'sl', 'somali': 'so', 'spanish': 'es', 'sundanese': 'su', 'swahili': 'sw', 'swedish': 'sv', 'tajik': 'tg', 'tamil': 'ta', 'telugu': 'te', 'thai': 'th', 'turkish': 'tr', 'ukrainian': 'uk', 'urdu': 'ur', 'uyghur': 'ug', 'uzbek': 'uz', 'vietnamese': 'vi', 'welsh': 'cy', 'xhosa': 'xh', 'yiddish': 'yi', 'yoruba': 'yo', 'zulu': 'zu'}

# Functions to Run
pygame.mixer.init()
def sound(event=None):
    try:
        pygame.mixer.music.load("Your Song.mp3")
        pygame.mixer.music.play()
        word3 = TextBlob(varname1.get())
        lan = word3.detect_language()
        lan_todict = language.get()
        lan_to = lan_dict[lan_todict]
        word3 = word3.translate(from_lang=lan, to=lan_to)
        varname2.set(word3)
    except:
        varname2.set("A Problem Has Been Occured")    
def mainexit():
    rr = messagebox.askyesnocancel('Exit Your Translator', 'Are You Want to Exit Kunal Translator Machine', parent= root)
    if (rr==True):
        root.destroy()

    # Binding [Hover] Functions 
def on_entry1click(e):
    entry1['bg'] = "lightblue"
def on_entry1leave(e):
    entry1['bg'] = "lightgreen"

def on_click(e):
    btn1['bg'] =  "green"
    btn1['foreground'] =  "black"
def on_leave(e):
    btn1['bg'] =  "pink"
    btn1['foreground'] =  "red" 
def on_2click(e):
    btn2['bg'] =  "black"  
    btn2['foreground'] =  "blue"  
def on_2leave(e):
    btn2['bg'] =  "red" 
    btn2['foreground'] =  "white"   

# Combo Box

language = StringVar()
font_box = Combobox(root, width=30, textvariable = language, state="readonly")
font_box['values'] = [e for e in lan_dict.keys()]
font_box.current(37)
font_box.place(x=130, y=147)
# Title Of My Program
label1 = Label(root,foreground="aqua", text="Your Translator Machine", font=('Arial', 15, 'italic bold'), bg="grey")
label1.place(x=278, y=10)

# Translator Boxes

    #Text Feeder
varname1 = StringVar()
entry1 = Entry(root, width=30, bg="lightgreen", textvariable=varname1, font=('ubuntu', 15, 'bold'))
entry1.place(x=400, y=70)

    #Text Output
varname2 = StringVar()
entry2 = Entry(root, width=30, bg="purple", textvariable=varname2, font=('ubuntu', 15, 'bold'), state="readonly")
entry2.place(x=400, y=220)

# # Labels 

    #Translate To 
label4 = Label(root,foreground="white",  text="Translate To :-", font=('ubuntu', 8, 'bold'), bg="grey")
label4.place(x=34, y=147)    
    #Text Feeder Label
label1 = Label(root,foreground="yellow",  text="Enter The Word to Translate :-", font=('ubuntu', 15, 'bold'), bg="grey")
label1.place(x=38, y=70)
    #Text Output Label
label2 = Label(root,foreground="orange", text="Translated Word Here :-", font=('ubuntu', 15, 'bold'), bg="grey")
label2.place(x=56, y=220)

#Buttons Here

    # Translater Button

btn1 = Button(root, text="Translate",  bg="pink", foreground="red",command= sound, font=('ubuntu', 15, 'bold'),relief=RAISED,\
                         cursor="hand2")
btn1.place(x=350, y=140)
root.bind('<Return>, sound)

    # Exit Button

btn2 = Button(root, text="Exit", bg="red",command= mainexit, foreground="white", padx=18, pady=8, font=('ubuntu', 15, 'bold'),relief=RAISED,\
                         cursor="hand2")
btn2.place(x=350, y=350)

#Binding 

    #Text Feeder Binding
entry1.bind('<Enter>', on_entry1click)
entry1.bind('<Leave>', on_entry1leave)


    #Translate Button Binding
btn1.bind('<Enter>', on_click)
btn1.bind('<Leave>', on_leave)

    #Exit Button Binding
btn2.bind('<Enter>', on_2click)
btn2.bind('<Leave>', on_2leave)



root.mainloop()
    

You can Edit these Codes to Make it Your Personal Translator

Friday, September 11, 2020

Addition Mini Calculator Using Java | Source Code | Full Details | More Information

Macstock

Simple Calculator Using Java

In this Java Program, I have managed to build a Mini Adding Calculator Using Java, So If you want then Copy the Codes from Below.

If You are a Advanced Java Programmer, Then It is Not For You. This Program Is Only For Beginners Or InterMediate Java Programmers Because It is Not GUI(Graphical User Interface) Program.

Things to Do Before Copying Codes

1. Make Sure You have Installed Java and Its JDK

2. Create A New Folder WhereEver You Want

3. Create a New File in The Folder Name "Anything.bat"

4. Right Click On the File and Click Edit And Paste the Given Text There.

java -jar JavaCalculator.jar


    import java.util.Scanner;
              
public class Main {
              
                  public static void main(String[] args) throws InterruptedException {
                      for (int i = 0; i < 2000; i++) {
                          Scanner scanner = new Scanner(System.in);
                          double a, b;
                          System.out.print("Enter The First Number to add : ");
                          a = scanner.nextDouble();
                          System.out.print("Enter the Second Number to add: ");
                          b = scanner.nextDouble();
                          System.out.println();
                          System.out.println();
                          System.out.println(a+b);
                          }
                         }
                        }
    

Make Sure To Build This in .jar Format and Save the File Name As "JavaCalculator.jar"

You can Use This As Much As You Want Coz This is In A Loop